quickwin 2.2.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +7 -7
- package/README.md +7 -7
- package/constants.ts +1070 -0
- package/enum_map.d.ts +130 -0
- package/examples/PdfCanvas.js +2 -2
- package/examples/PdfCanvas.tsx +3 -2
- package/examples/{execd.js → execd/main.js} +717 -148
- package/examples/execd/tray.js +192 -0
- package/examples/{execd_worker.js → execd/worker.js} +7 -7
- package/examples/pdf_preview2.js +46 -46
- package/examples/pdf_preview2.ts +55 -54
- package/examples/pdf_viewer.js +34 -19
- package/examples/pdf_viewer.tsx +6 -5
- package/examples/test_gallery.js +35 -20
- package/examples/test_gallery.tsx +9 -8
- package/examples/test_react_lazy.js +34 -19
- package/examples/test_react_lazy.tsx +7 -6
- package/examples/test_react_listbox.js +34 -19
- package/examples/test_react_listbox.tsx +8 -7
- package/examples/test_root_window.js +34 -19
- package/examples/test_root_window.tsx +5 -5
- package/examples/test_tab.js +34 -19
- package/examples/test_tab.tsx +7 -6
- package/examples/tray_demo.js +8 -8
- package/examples/tray_demo.tsx +9 -8
- package/lib/dumpRects.js +2 -2
- package/lib/dumpRects.ts +3 -2
- package/lib/fetch.js +15 -15
- package/lib/fetch.ts +16 -15
- package/lib/ffi/bind.js +3 -3
- package/lib/ffi/bind.ts +3 -3
- package/lib/http-server.js +54 -29
- package/lib/http-server.ts +56 -27
- package/lib/react-qw/components/Button.js +2 -2
- package/lib/react-qw/components/CheckBox.js +4 -4
- package/lib/react-qw/components/ComboBox.js +10 -10
- package/lib/react-qw/components/DateTimePicker.js +12 -12
- package/lib/react-qw/components/Input.js +7 -7
- package/lib/react-qw/components/Link.js +4 -4
- package/lib/react-qw/components/ListBox.js +12 -12
- package/lib/react-qw/components/ListView.js +35 -35
- package/lib/react-qw/components/PathPicker.js +3 -3
- package/lib/react-qw/components/ProgressBar.js +4 -4
- package/lib/react-qw/components/RadioButton.js +4 -4
- package/lib/react-qw/components/ScrollView.js +28 -28
- package/lib/react-qw/components/Slider.js +11 -11
- package/lib/react-qw/components/Tab.js +10 -10
- package/lib/react-qw/components/Tooltip.js +8 -8
- package/lib/react-qw/components/TreeView.js +20 -20
- package/lib/react-qw/index.js +5 -5
- package/lib/react-qw/index.ts +6 -5
- package/lib/react-qw/props.js +4 -4
- package/lib/react-qw/props.ts +5 -4
- package/lib/react-qw/reconciler.js +10 -10
- package/lib/react-qw/reconciler.ts +11 -10
- package/lib/text-measure.js +3 -3
- package/lib/text-measure.ts +4 -3
- package/lib/websocket.js +17 -17
- package/lib/websocket.ts +18 -17
- package/lib/windows/advapi32.js +7 -7
- package/lib/windows/advapi32.ts +7 -7
- package/lib/windows/gdi32.js +16 -16
- package/lib/windows/gdi32.ts +16 -16
- package/lib/windows/kernel32.js +41 -2
- package/lib/windows/kernel32.ts +45 -2
- package/lib/windows/shell32.js +24 -3
- package/lib/windows/shell32.ts +27 -4
- package/lib/windows/structs.js +54 -0
- package/lib/windows/structs.ts +63 -1
- package/lib/windows/user32.js +18 -6
- package/lib/windows/user32.ts +18 -6
- package/lib/windows/winspool.js +3 -3
- package/lib/windows/winspool.ts +3 -3
- package/package.json +4 -3
- package/quickwin.d.ts +32 -10
- package/qwin-nowasm-x86.exe +0 -0
- package/qwin-nowasm.exe +0 -0
- package/qwin-x86.exe +0 -0
- package/qwin.exe +0 -0
- package/test/test_ffi_bind.js +7 -7
- package/test/test_ffi_bind.ts +8 -8
- package/test/test_ffi_struct.js +2 -2
- package/test/test_ffi_struct.ts +3 -3
- package/test/test_ffi_windows.js +1 -1
- package/test/test_ffi_windows.ts +1 -1
- package/test/test_files.js +7 -7
- package/test/test_files.ts +8 -8
- package/test/test_gdi_draw.js +51 -51
- package/test/test_gdi_draw.ts +57 -57
- package/test/test_http_server.js +3 -3
- package/test/test_http_server.ts +4 -3
- package/test/test_ipv6.js +3 -3
- package/test/test_ipv6.ts +4 -3
- package/test/test_net_event.js +3 -3
- package/test/test_net_event.ts +4 -3
- package/test/test_printer.js +4 -4
- package/test/test_printer.ts +5 -5
- package/test/test_react_complex.js +36 -21
- package/test/test_react_counter.js +34 -19
- package/test/test_react_flex.js +36 -21
- package/test/test_react_hidden.js +34 -19
- package/test/test_react_listview_link.js +35 -20
- package/test/test_react_notify.js +52 -37
- package/test/test_react_render.js +34 -19
- package/test/test_registry.js +6 -6
- package/test/test_registry.ts +8 -8
- package/test/test_wolfssl_read.js +8 -8
- package/test/test_wolfssl_read.ts +9 -8
- package/examples/execd.tsx +0 -798
- package/examples/execd_worker.ts +0 -127
- package/quickwin_const.d.ts +0 -1063
package/lib/windows/kernel32.js
CHANGED
|
@@ -101,6 +101,38 @@ export const TerminateProcess = /*@__PURE__*/ b('TerminateProcess', '<HPROCESS>p
|
|
|
101
101
|
/** 取当前进程 PID(互证锚点)
|
|
102
102
|
* @returns 当前进程 PID */
|
|
103
103
|
export const GetCurrentProcessId = /*@__PURE__*/ b('GetCurrentProcessId', ' -> u32');
|
|
104
|
+
/** 当前进程伪句柄(-1,不需 CloseHandle——OpenProcess 真句柄的零成本替代,纯本进程
|
|
105
|
+
* 场景如 IsWow64Process 探位宽用) */
|
|
106
|
+
export const GetCurrentProcess = /*@__PURE__*/ b('GetCurrentProcess', ' -> <HPROCESS>ptr');
|
|
107
|
+
// ============ 远程内存(跨进程 SendMessage 的输出缓冲)============
|
|
108
|
+
// 普通跨进程 SendMessage **不 marshal 指针**:出参 buffer 写在接收方线程执行,指针值
|
|
109
|
+
// 原样透传——落在本进程地址空间会被 explorer 直接写穿。正解 = VirtualAllocEx 在目标
|
|
110
|
+
// 进程分配 → 发消息 → ReadProcessMemory 读回(见 examples/execd/tray.ts /tray_list 用例)。
|
|
111
|
+
/** 在目标进程地址空间分配内存;配对 VirtualFreeEx
|
|
112
|
+
* @returns 成功 → 远程基址,失败 → 0(0 保真)
|
|
113
|
+
* @param args_0 hProcess OpenProcess 句柄(本场景须 PROCESS_VM_OPERATION(0x8) |
|
|
114
|
+
* PROCESS_VM_READ(0x10) | PROCESS_VM_WRITE(0x20) = 0x38)
|
|
115
|
+
* @param args_1 lpAddress NULL = 系统选起点
|
|
116
|
+
* @param args_2 dwSize 字节数(SIZE_T 随位宽 = <>ptr 的 ptr 宽,非指针语义)
|
|
117
|
+
* @param args_3 flAllocationType MEM_COMMIT|MEM_RESERVE(0x1000|0x2000 = 0x3000)
|
|
118
|
+
* @param args_4 flProtect PAGE_READWRITE(0x04) */
|
|
119
|
+
export const VirtualAllocEx = /*@__PURE__*/ b('VirtualAllocEx', '<HPROCESS>ptr <>ptr <>ptr u32 u32 -> <>ptr');
|
|
120
|
+
/** 释放 VirtualAllocEx 内存(须同一进程句柄)
|
|
121
|
+
* @returns 成功 → 非 0
|
|
122
|
+
* @param args_0 hProcess 同 VirtualAllocEx
|
|
123
|
+
* @param args_1 lpAddress VirtualAllocEx 返回的远程基址
|
|
124
|
+
* @param args_2 dwSize 0(MEM_RELEASE 时必须 0)
|
|
125
|
+
* @param args_3 dwFreeType MEM_RELEASE(0x8000) */
|
|
126
|
+
export const VirtualFreeEx = /*@__PURE__*/ b('VirtualFreeEx', '<HPROCESS>ptr <>ptr <>ptr u32 -> i32');
|
|
127
|
+
/** 读目标进程内存(远程 SendMessage 写完 → 本调用读回本地;远程指针字段如托盘
|
|
128
|
+
* dwData 内容的二次解引用同样走这里)
|
|
129
|
+
* @returns 成功 → 非 0(目标地址不可读/句柄无 PROCESS_VM_READ)
|
|
130
|
+
* @param args_0 hProcess OpenProcess 句柄(须 PROCESS_VM_READ(0x10))
|
|
131
|
+
* @param args_1 lpBaseAddress 远程地址(VirtualAllocEx 返回值等)
|
|
132
|
+
* @param args_2 lpBuffer 本地接收缓冲,传 BYTE.alloc(n)(DataView/TypedArray 原地读回)
|
|
133
|
+
* @param args_3 nSize 字节数(SIZE_T → <>ptr ptr 宽)
|
|
134
|
+
* @param args_4 lpNumberOfBytesRead 实读字节数出参槽 PtrArrayBuffer(8) 可选,或 NULL */
|
|
135
|
+
export const ReadProcessMemory = /*@__PURE__*/ b('ReadProcessMemory', '<HPROCESS>ptr <>ptr <BYTE>ptr <>ptr <>ptr -> i32');
|
|
104
136
|
// ============ 文件 I/O ============
|
|
105
137
|
/** 同步读文件 / 管道
|
|
106
138
|
* @returns 成功 → 非 0,管道写端全部关闭后读返回 0(EOF)
|
|
@@ -118,7 +150,7 @@ export const ReadFile = /*@__PURE__*/ b('ReadFile', '<HFILE>ptr! <BYTE>ptr u32 <
|
|
|
118
150
|
* 组合(flags 位不标枚举)
|
|
119
151
|
* @param args_2 dwShareMode 共享掩码:FILE_SHARE_READ(0x1)|FILE_SHARE_WRITE(0x2),独占传 0
|
|
120
152
|
* @param args_3 lpSecurityAttributes 安全属性,传 NULL
|
|
121
|
-
* @param args_4 dwCreationDisposition 创建处置
|
|
153
|
+
* @param args_4 dwCreationDisposition 创建处置 FileCreation.*(互斥单选)
|
|
122
154
|
* @param args_5 dwFlagsAndAttributes 属性:FILE_ATTRIBUTE_NORMAL(0x80) 等(可组合不标)
|
|
123
155
|
* @param args_6 hTemplateFile 模板文件句柄,传 NULL */
|
|
124
156
|
export const CreateFile = /*@__PURE__*/ b('CreateFileW', '<WCHAR>ptr! u32 u32 <>ptr u32@FileCreation u32 <>ptr -> <HFILE>ptr!');
|
|
@@ -157,7 +189,7 @@ export const MoveFileEx = /*@__PURE__*/ b('MoveFileExW', '<WCHAR>ptr! <WCHAR>ptr
|
|
|
157
189
|
* 与合法的 0xFFFFFFFF 偏移)
|
|
158
190
|
* @param args_1 lDistanceToMove 偏移(LONG,可负)
|
|
159
191
|
* @param args_2 lpDistanceToMoveHigh 64 位偏移高半(出参双向),32 位够用传 NULL
|
|
160
|
-
* @param args_3 dwMoveMethod 起点
|
|
192
|
+
* @param args_3 dwMoveMethod 起点 FileSeekFrom.BEGIN / CURRENT / END */
|
|
161
193
|
export const SetFilePointer = /*@__PURE__*/ b('SetFilePointer', '<HFILE>ptr! i32 <BYTE>ptr u32@FileSeekFrom -> u32');
|
|
162
194
|
/** 读文件大小
|
|
163
195
|
* @returns 文件大小(低 32 位);0xFFFFFFFF = 失败(INVALID_FILE_SIZE,须 GetLastError 区分)
|
|
@@ -238,6 +270,13 @@ export const GetModuleFileName = /*@__PURE__*/ b('GetModuleFileNameW', '<HMODULE
|
|
|
238
270
|
* @returns 命令行整串(返回位 `<WCHAR>ptr!`:内建 WCHAR codec 自动解码为 string,
|
|
239
271
|
* `!` 担保非 NULL 由返回位 0 检查兜底,无需接收缓冲) */
|
|
240
272
|
export const GetCommandLineW = /*@__PURE__*/ b('GetCommandLineW', ' -> <WCHAR>ptr!');
|
|
273
|
+
/** 本进程是否跑在 WOW64(32 位进程 on 64 位 OS)——判**远程进程/系统位宽**的廉价
|
|
274
|
+
* 探针:x64 进程恒 0(本就是 64 位 OS);x86 进程 1 = OS 64 位(远程序构按 64 位解析,
|
|
275
|
+
* 如 x86 qwin 读 explorer 的 TBBUTTON)。32 位 OS 上恒写 0
|
|
276
|
+
* @returns 成功 → 非 0
|
|
277
|
+
* @param args_0 hProcess GetCurrentProcess() 伪句柄或真句柄
|
|
278
|
+
* @param args_1 lpWow64Process 出参 BOOL 槽,PtrArrayBuffer(4),Uint32Array 读回 */
|
|
279
|
+
export const IsWow64Process = /*@__PURE__*/ b('IsWow64Process', '<HPROCESS>ptr <BYTE>ptr -> i32');
|
|
241
280
|
// ============ 全局内存(剪贴板数据载体)============
|
|
242
281
|
/** 分配全局内存块
|
|
243
282
|
* @returns 成功 → 句柄(0 失败)
|
package/lib/windows/kernel32.ts
CHANGED
|
@@ -117,6 +117,42 @@ export const TerminateProcess = /*@__PURE__*/ b('TerminateProcess', '<HPROCESS>p
|
|
|
117
117
|
/** 取当前进程 PID(互证锚点)
|
|
118
118
|
* @returns 当前进程 PID */
|
|
119
119
|
export const GetCurrentProcessId = /*@__PURE__*/ b('GetCurrentProcessId', ' -> u32')
|
|
120
|
+
/** 当前进程伪句柄(-1,不需 CloseHandle——OpenProcess 真句柄的零成本替代,纯本进程
|
|
121
|
+
* 场景如 IsWow64Process 探位宽用) */
|
|
122
|
+
export const GetCurrentProcess = /*@__PURE__*/ b('GetCurrentProcess', ' -> <HPROCESS>ptr')
|
|
123
|
+
|
|
124
|
+
// ============ 远程内存(跨进程 SendMessage 的输出缓冲)============
|
|
125
|
+
// 普通跨进程 SendMessage **不 marshal 指针**:出参 buffer 写在接收方线程执行,指针值
|
|
126
|
+
// 原样透传——落在本进程地址空间会被 explorer 直接写穿。正解 = VirtualAllocEx 在目标
|
|
127
|
+
// 进程分配 → 发消息 → ReadProcessMemory 读回(见 examples/execd/tray.ts /tray_list 用例)。
|
|
128
|
+
|
|
129
|
+
/** 在目标进程地址空间分配内存;配对 VirtualFreeEx
|
|
130
|
+
* @returns 成功 → 远程基址,失败 → 0(0 保真)
|
|
131
|
+
* @param args_0 hProcess OpenProcess 句柄(本场景须 PROCESS_VM_OPERATION(0x8) |
|
|
132
|
+
* PROCESS_VM_READ(0x10) | PROCESS_VM_WRITE(0x20) = 0x38)
|
|
133
|
+
* @param args_1 lpAddress NULL = 系统选起点
|
|
134
|
+
* @param args_2 dwSize 字节数(SIZE_T 随位宽 = <>ptr 的 ptr 宽,非指针语义)
|
|
135
|
+
* @param args_3 flAllocationType MEM_COMMIT|MEM_RESERVE(0x1000|0x2000 = 0x3000)
|
|
136
|
+
* @param args_4 flProtect PAGE_READWRITE(0x04) */
|
|
137
|
+
export const VirtualAllocEx = /*@__PURE__*/ b('VirtualAllocEx',
|
|
138
|
+
'<HPROCESS>ptr <>ptr <>ptr u32 u32 -> <>ptr')
|
|
139
|
+
/** 释放 VirtualAllocEx 内存(须同一进程句柄)
|
|
140
|
+
* @returns 成功 → 非 0
|
|
141
|
+
* @param args_0 hProcess 同 VirtualAllocEx
|
|
142
|
+
* @param args_1 lpAddress VirtualAllocEx 返回的远程基址
|
|
143
|
+
* @param args_2 dwSize 0(MEM_RELEASE 时必须 0)
|
|
144
|
+
* @param args_3 dwFreeType MEM_RELEASE(0x8000) */
|
|
145
|
+
export const VirtualFreeEx = /*@__PURE__*/ b('VirtualFreeEx', '<HPROCESS>ptr <>ptr <>ptr u32 -> i32')
|
|
146
|
+
/** 读目标进程内存(远程 SendMessage 写完 → 本调用读回本地;远程指针字段如托盘
|
|
147
|
+
* dwData 内容的二次解引用同样走这里)
|
|
148
|
+
* @returns 成功 → 非 0(目标地址不可读/句柄无 PROCESS_VM_READ)
|
|
149
|
+
* @param args_0 hProcess OpenProcess 句柄(须 PROCESS_VM_READ(0x10))
|
|
150
|
+
* @param args_1 lpBaseAddress 远程地址(VirtualAllocEx 返回值等)
|
|
151
|
+
* @param args_2 lpBuffer 本地接收缓冲,传 BYTE.alloc(n)(DataView/TypedArray 原地读回)
|
|
152
|
+
* @param args_3 nSize 字节数(SIZE_T → <>ptr ptr 宽)
|
|
153
|
+
* @param args_4 lpNumberOfBytesRead 实读字节数出参槽 PtrArrayBuffer(8) 可选,或 NULL */
|
|
154
|
+
export const ReadProcessMemory = /*@__PURE__*/ b('ReadProcessMemory',
|
|
155
|
+
'<HPROCESS>ptr <>ptr <BYTE>ptr <>ptr <>ptr -> i32')
|
|
120
156
|
|
|
121
157
|
// ============ 文件 I/O ============
|
|
122
158
|
|
|
@@ -137,7 +173,7 @@ export const ReadFile = /*@__PURE__*/ b('ReadFile', '<HFILE>ptr! <BYTE>ptr u32 <
|
|
|
137
173
|
* 组合(flags 位不标枚举)
|
|
138
174
|
* @param args_2 dwShareMode 共享掩码:FILE_SHARE_READ(0x1)|FILE_SHARE_WRITE(0x2),独占传 0
|
|
139
175
|
* @param args_3 lpSecurityAttributes 安全属性,传 NULL
|
|
140
|
-
* @param args_4 dwCreationDisposition 创建处置
|
|
176
|
+
* @param args_4 dwCreationDisposition 创建处置 FileCreation.*(互斥单选)
|
|
141
177
|
* @param args_5 dwFlagsAndAttributes 属性:FILE_ATTRIBUTE_NORMAL(0x80) 等(可组合不标)
|
|
142
178
|
* @param args_6 hTemplateFile 模板文件句柄,传 NULL */
|
|
143
179
|
export const CreateFile = /*@__PURE__*/ b('CreateFileW',
|
|
@@ -177,7 +213,7 @@ export const MoveFileEx = /*@__PURE__*/ b('MoveFileExW', '<WCHAR>ptr! <WCHAR>ptr
|
|
|
177
213
|
* 与合法的 0xFFFFFFFF 偏移)
|
|
178
214
|
* @param args_1 lDistanceToMove 偏移(LONG,可负)
|
|
179
215
|
* @param args_2 lpDistanceToMoveHigh 64 位偏移高半(出参双向),32 位够用传 NULL
|
|
180
|
-
* @param args_3 dwMoveMethod 起点
|
|
216
|
+
* @param args_3 dwMoveMethod 起点 FileSeekFrom.BEGIN / CURRENT / END */
|
|
181
217
|
export const SetFilePointer = /*@__PURE__*/ b('SetFilePointer', '<HFILE>ptr! i32 <BYTE>ptr u32@FileSeekFrom -> u32')
|
|
182
218
|
/** 读文件大小
|
|
183
219
|
* @returns 文件大小(低 32 位);0xFFFFFFFF = 失败(INVALID_FILE_SIZE,须 GetLastError 区分)
|
|
@@ -265,6 +301,13 @@ export const GetModuleFileName = /*@__PURE__*/ b('GetModuleFileNameW', '<HMODULE
|
|
|
265
301
|
* @returns 命令行整串(返回位 `<WCHAR>ptr!`:内建 WCHAR codec 自动解码为 string,
|
|
266
302
|
* `!` 担保非 NULL 由返回位 0 检查兜底,无需接收缓冲) */
|
|
267
303
|
export const GetCommandLineW = /*@__PURE__*/ b('GetCommandLineW', ' -> <WCHAR>ptr!')
|
|
304
|
+
/** 本进程是否跑在 WOW64(32 位进程 on 64 位 OS)——判**远程进程/系统位宽**的廉价
|
|
305
|
+
* 探针:x64 进程恒 0(本就是 64 位 OS);x86 进程 1 = OS 64 位(远程序构按 64 位解析,
|
|
306
|
+
* 如 x86 qwin 读 explorer 的 TBBUTTON)。32 位 OS 上恒写 0
|
|
307
|
+
* @returns 成功 → 非 0
|
|
308
|
+
* @param args_0 hProcess GetCurrentProcess() 伪句柄或真句柄
|
|
309
|
+
* @param args_1 lpWow64Process 出参 BOOL 槽,PtrArrayBuffer(4),Uint32Array 读回 */
|
|
310
|
+
export const IsWow64Process = /*@__PURE__*/ b('IsWow64Process', '<HPROCESS>ptr <BYTE>ptr -> i32')
|
|
268
311
|
|
|
269
312
|
// ============ 全局内存(剪贴板数据载体)============
|
|
270
313
|
|
package/lib/windows/shell32.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
// shell32 绑定(shell 对话框 / PIDL
|
|
1
|
+
// shell32 绑定(shell 对话框 / PIDL→路径 / 托盘图标定位)
|
|
2
2
|
import { bind } from '../ffi/bind.js';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { NOTIFYICONIDENTIFIER } from './structs.js';
|
|
4
|
+
// dll 名部分应用(工厂转调保泛型 infer,见 lib/windows/user32.ts 头注释);第三参透传
|
|
5
|
+
// encoders(结构入参位注册,方向约定见 lib/windows/user32.ts 头注释)
|
|
6
|
+
const b = (name, sig, encoders) => bind('shell32.dll', name, sig, encoders);
|
|
5
7
|
/** 文件夹浏览对话框;PIDL 用 ole32.CoTaskMemFree 释放
|
|
6
8
|
* @returns PIDL,取消 → 0
|
|
7
9
|
* @param args_0 pbi BROWSEINFOW.encode(...).ptr(见 structs.ts) */
|
|
@@ -11,3 +13,22 @@ export const SHBrowseForFolder = /*@__PURE__*/ b('SHBrowseForFolderW', '<BROWSEI
|
|
|
11
13
|
* @param args_0 pidl SHBrowseForFolder 等返回的 PIDL
|
|
12
14
|
* @param args_1 pszPath 出参缓冲,WCHAR.alloc(260)(MAX_PATH=260)、WCHAR.decode 读回 */
|
|
13
15
|
export const SHGetPathFromIDList = /*@__PURE__*/ b('SHGetPathFromIDListW', '<>ptr <BYTE>ptr -> u32');
|
|
16
|
+
/** 取托盘通知图标的屏幕矩形(Shell_NotifyIconGetRect;**Win7+**——XP 无此导出,
|
|
17
|
+
* 故为**可选绑定**:老系统上本常量为 null(bind() 是模块顶层立即解析,缺符号 throw
|
|
18
|
+
* 会拖垮整个脚本启动),调用方必须判空)
|
|
19
|
+
* @returns HRESULT,实测语义:0 = 图标在通知区内,iconLocation = 其容器(可见区 /
|
|
20
|
+
* 溢出面板)内位置——**溢出面板未展开时该 rect 不是屏幕可点位**;1 = 按文档为
|
|
21
|
+
* 不可见态(隐藏/溢出;本机未复现——实测 Win7 溢出图标亦返 0);0x80004005 E_FAIL
|
|
22
|
+
* = 图标不存在,或该图标未按 {hWnd,uID} 注册(系统 GUID 图标实测 not_found)
|
|
23
|
+
* @param args_0 identifier NOTIFYICONIDENTIFIER 对象直传(encoder 已注册;cbSize 填
|
|
24
|
+
* NOTIFYICONIDENTIFIER.size,guidItem 缺省 = GUID_NULL 走 hWnd+uID)
|
|
25
|
+
* @param args_1 iconLocation 出参槽,RECT.alloc().ptr(出参位不注册,方向约定同
|
|
26
|
+
* user32),RECT.decode 读回 */
|
|
27
|
+
export const Shell_NotifyIconGetRect = (() => {
|
|
28
|
+
try {
|
|
29
|
+
return b('Shell_NotifyIconGetRect', '<NOTIFYICONIDENTIFIER>ptr <RECT>ptr -> i32', { NOTIFYICONIDENTIFIER });
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return null; // XP 等老系统无此导出(可选 API);探测走 examples/execd/tray.ts
|
|
33
|
+
}
|
|
34
|
+
})();
|
package/lib/windows/shell32.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
// shell32 绑定(shell 对话框 / PIDL
|
|
2
|
-
import { bind } from '../ffi/bind.js'
|
|
1
|
+
// shell32 绑定(shell 对话框 / PIDL→路径 / 托盘图标定位)
|
|
2
|
+
import { bind, type CodecMap } from '../ffi/bind.js'
|
|
3
|
+
import { NOTIFYICONIDENTIFIER } from './structs.js'
|
|
3
4
|
|
|
4
|
-
// dll 名部分应用(工厂转调保泛型 infer,见 lib/windows/user32.ts
|
|
5
|
-
|
|
5
|
+
// dll 名部分应用(工厂转调保泛型 infer,见 lib/windows/user32.ts 头注释);第三参透传
|
|
6
|
+
// encoders(结构入参位注册,方向约定见 lib/windows/user32.ts 头注释)
|
|
7
|
+
const b = <const S extends string, const LE extends CodecMap = {}>(name: string, sig: S, encoders?: LE) =>
|
|
8
|
+
bind('shell32.dll', name, sig, encoders)
|
|
6
9
|
|
|
7
10
|
/** 文件夹浏览对话框;PIDL 用 ole32.CoTaskMemFree 释放
|
|
8
11
|
* @returns PIDL,取消 → 0
|
|
@@ -14,3 +17,23 @@ export const SHBrowseForFolder = /*@__PURE__*/ b('SHBrowseForFolderW', '<BROWSEI
|
|
|
14
17
|
* @param args_0 pidl SHBrowseForFolder 等返回的 PIDL
|
|
15
18
|
* @param args_1 pszPath 出参缓冲,WCHAR.alloc(260)(MAX_PATH=260)、WCHAR.decode 读回 */
|
|
16
19
|
export const SHGetPathFromIDList = /*@__PURE__*/ b('SHGetPathFromIDListW', '<>ptr <BYTE>ptr -> u32')
|
|
20
|
+
|
|
21
|
+
/** 取托盘通知图标的屏幕矩形(Shell_NotifyIconGetRect;**Win7+**——XP 无此导出,
|
|
22
|
+
* 故为**可选绑定**:老系统上本常量为 null(bind() 是模块顶层立即解析,缺符号 throw
|
|
23
|
+
* 会拖垮整个脚本启动),调用方必须判空)
|
|
24
|
+
* @returns HRESULT,实测语义:0 = 图标在通知区内,iconLocation = 其容器(可见区 /
|
|
25
|
+
* 溢出面板)内位置——**溢出面板未展开时该 rect 不是屏幕可点位**;1 = 按文档为
|
|
26
|
+
* 不可见态(隐藏/溢出;本机未复现——实测 Win7 溢出图标亦返 0);0x80004005 E_FAIL
|
|
27
|
+
* = 图标不存在,或该图标未按 {hWnd,uID} 注册(系统 GUID 图标实测 not_found)
|
|
28
|
+
* @param args_0 identifier NOTIFYICONIDENTIFIER 对象直传(encoder 已注册;cbSize 填
|
|
29
|
+
* NOTIFYICONIDENTIFIER.size,guidItem 缺省 = GUID_NULL 走 hWnd+uID)
|
|
30
|
+
* @param args_1 iconLocation 出参槽,RECT.alloc().ptr(出参位不注册,方向约定同
|
|
31
|
+
* user32),RECT.decode 读回 */
|
|
32
|
+
export const Shell_NotifyIconGetRect = (() => {
|
|
33
|
+
try {
|
|
34
|
+
return b('Shell_NotifyIconGetRect',
|
|
35
|
+
'<NOTIFYICONIDENTIFIER>ptr <RECT>ptr -> i32', { NOTIFYICONIDENTIFIER })
|
|
36
|
+
} catch {
|
|
37
|
+
return null // XP 等老系统无此导出(可选 API);探测走 examples/execd/tray.ts
|
|
38
|
+
}
|
|
39
|
+
})()
|
package/lib/windows/structs.js
CHANGED
|
@@ -601,3 +601,57 @@ export const PROCESS_MEMORY_COUNTERS_DECL = {
|
|
|
601
601
|
PeakPagefileUsage: '<>ptr',
|
|
602
602
|
};
|
|
603
603
|
export const PROCESS_MEMORY_COUNTERS = /* @__PURE__ */ struct('PROCESS_MEMORY_COUNTERS', PROCESS_MEMORY_COUNTERS_DECL);
|
|
604
|
+
/** MOUSEINPUT(SendInput 鼠标事件体;x86 24B / x64 32B——dwExtraInfo 是 ULONG_PTR,
|
|
605
|
+
* 随位宽)。dx/dy 相对位移,或 dwFlags 带 MOUSEEVENTF_ABSOLUTE 时为 0-65535 归一化
|
|
606
|
+
* 物理像素(本引擎 SetProcessDPIAware,见 src/main.c,全坐标 API 同空间);
|
|
607
|
+
* mouseData 滚轮增量(±120)或 X 系按钮编号(XBUTTON1/2) */
|
|
608
|
+
export const MOUSEINPUT_DECL = {
|
|
609
|
+
'#': 'struct',
|
|
610
|
+
dx: 'i32',
|
|
611
|
+
dy: 'i32',
|
|
612
|
+
mouseData: 'u32',
|
|
613
|
+
dwFlags: 'u32',
|
|
614
|
+
time: 'u32',
|
|
615
|
+
dwExtraInfo: '<>ptr',
|
|
616
|
+
};
|
|
617
|
+
export const MOUSEINPUT = /* @__PURE__ */ struct('MOUSEINPUT', MOUSEINPUT_DECL);
|
|
618
|
+
/** KEYBDINPUT(SendInput 键盘事件体;x86 16B / x64 24B):wVk 虚拟键码,
|
|
619
|
+
* dwFlags 带 KEYEVENTF_UNICODE 时 wScan = 字符码 */
|
|
620
|
+
export const KEYBDINPUT_DECL = {
|
|
621
|
+
'#': 'struct',
|
|
622
|
+
wVk: 'u16',
|
|
623
|
+
wScan: 'u16',
|
|
624
|
+
dwFlags: 'u32',
|
|
625
|
+
time: 'u32',
|
|
626
|
+
dwExtraInfo: '<>ptr',
|
|
627
|
+
};
|
|
628
|
+
export const KEYBDINPUT = /* @__PURE__ */ struct('KEYBDINPUT', KEYBDINPUT_DECL);
|
|
629
|
+
/** INPUT(SendInput 元素;x86 28B / x64 40B):type(INPUT_MOUSE=0 / INPUT_KEYBOARD=1)
|
|
630
|
+
* + 三选一 union——C 的 DUMMYUNIONNAME 匿名成员在此命名嵌套(encode 形
|
|
631
|
+
* {type, data:{mi|ki:{...}}})。union 随 MOUSEINPUT 的 ULONG_PTR 位宽,x64 下 type 后
|
|
632
|
+
* 自动补 4B padding 使 union 8 对齐(MSVC 布局)。HARDWAREINPUT 不注入,省略不改
|
|
633
|
+
* 尺寸(union 尺寸 = max 成员 = MOUSEINPUT)。dwExtraInfo 是 ULONG_PTR 信息位(非句柄)
|
|
634
|
+
* → <>ptr 裸档(uintptr 双态先例:WPARAM/LPARAM/void*),恒传 0 */
|
|
635
|
+
export const INPUT_DECL = {
|
|
636
|
+
'#': 'struct',
|
|
637
|
+
type: 'u32',
|
|
638
|
+
data: {
|
|
639
|
+
'#': 'union',
|
|
640
|
+
mi: MOUSEINPUT_DECL,
|
|
641
|
+
ki: KEYBDINPUT_DECL,
|
|
642
|
+
},
|
|
643
|
+
};
|
|
644
|
+
export const INPUT = /* @__PURE__ */ struct('INPUT', INPUT_DECL);
|
|
645
|
+
/** NOTIFYICONIDENTIFIER(Shell_NotifyIconGetRect 定位托盘通知图标;x86 28B / x64 40B——
|
|
646
|
+
* hWnd 是 HWND 随位宽,guidItem = GUID 固定 16B 不随)。定位二法取一:guidItem 非全 0
|
|
647
|
+
* 时忽略 hWnd/uID,否则走 hWnd+uID(deskmon 等自注册图标即此形,与 Shell_NotifyIcon
|
|
648
|
+
* 的 {hwnd,uID} 同源);guidItem 缺省 = GUID_NULL 走 hWnd+uID。cbSize 调用前填
|
|
649
|
+
* NOTIFYICONIDENTIFIER.size(cb 结构惯例,见 PROCESS_MEMORY_COUNTERS 同) */
|
|
650
|
+
export const NOTIFYICONIDENTIFIER_DECL = {
|
|
651
|
+
'#': 'struct',
|
|
652
|
+
cbSize: 'u32',
|
|
653
|
+
hWnd: '<HWND>ptr',
|
|
654
|
+
uID: 'u32',
|
|
655
|
+
guidItem: 'u32[4]',
|
|
656
|
+
};
|
|
657
|
+
export const NOTIFYICONIDENTIFIER = /* @__PURE__ */ struct('NOTIFYICONIDENTIFIER', NOTIFYICONIDENTIFIER_DECL);
|
package/lib/windows/structs.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { struct } from '../ffi/struct.js'
|
|
2
|
-
import type { C_Struct } from '../ffi/ctype.js'
|
|
2
|
+
import type { C_Struct, C_Union } from '../ffi/ctype.js'
|
|
3
3
|
|
|
4
4
|
// 全仓库 Win32 结构的集中定义点(CType IR,按本机架构 MSVC 对齐;这批全为定长标量/字符串,
|
|
5
5
|
// ia32/x64 同布局)。形参位方向约定见 lib/windows/user32.ts 头注释:
|
|
@@ -688,3 +688,65 @@ export const PROCESS_MEMORY_COUNTERS_DECL = {
|
|
|
688
688
|
} satisfies C_Struct
|
|
689
689
|
|
|
690
690
|
export const PROCESS_MEMORY_COUNTERS = /* @__PURE__ */ struct('PROCESS_MEMORY_COUNTERS', PROCESS_MEMORY_COUNTERS_DECL)
|
|
691
|
+
|
|
692
|
+
/** MOUSEINPUT(SendInput 鼠标事件体;x86 24B / x64 32B——dwExtraInfo 是 ULONG_PTR,
|
|
693
|
+
* 随位宽)。dx/dy 相对位移,或 dwFlags 带 MOUSEEVENTF_ABSOLUTE 时为 0-65535 归一化
|
|
694
|
+
* 物理像素(本引擎 SetProcessDPIAware,见 src/main.c,全坐标 API 同空间);
|
|
695
|
+
* mouseData 滚轮增量(±120)或 X 系按钮编号(XBUTTON1/2) */
|
|
696
|
+
export const MOUSEINPUT_DECL = {
|
|
697
|
+
'#': 'struct',
|
|
698
|
+
dx: 'i32',
|
|
699
|
+
dy: 'i32',
|
|
700
|
+
mouseData: 'u32',
|
|
701
|
+
dwFlags: 'u32',
|
|
702
|
+
time: 'u32',
|
|
703
|
+
dwExtraInfo: '<>ptr',
|
|
704
|
+
} satisfies C_Struct
|
|
705
|
+
|
|
706
|
+
export const MOUSEINPUT = /* @__PURE__ */ struct('MOUSEINPUT', MOUSEINPUT_DECL)
|
|
707
|
+
|
|
708
|
+
/** KEYBDINPUT(SendInput 键盘事件体;x86 16B / x64 24B):wVk 虚拟键码,
|
|
709
|
+
* dwFlags 带 KEYEVENTF_UNICODE 时 wScan = 字符码 */
|
|
710
|
+
export const KEYBDINPUT_DECL = {
|
|
711
|
+
'#': 'struct',
|
|
712
|
+
wVk: 'u16',
|
|
713
|
+
wScan: 'u16',
|
|
714
|
+
dwFlags: 'u32',
|
|
715
|
+
time: 'u32',
|
|
716
|
+
dwExtraInfo: '<>ptr',
|
|
717
|
+
} satisfies C_Struct
|
|
718
|
+
|
|
719
|
+
export const KEYBDINPUT = /* @__PURE__ */ struct('KEYBDINPUT', KEYBDINPUT_DECL)
|
|
720
|
+
|
|
721
|
+
/** INPUT(SendInput 元素;x86 28B / x64 40B):type(INPUT_MOUSE=0 / INPUT_KEYBOARD=1)
|
|
722
|
+
* + 三选一 union——C 的 DUMMYUNIONNAME 匿名成员在此命名嵌套(encode 形
|
|
723
|
+
* {type, data:{mi|ki:{...}}})。union 随 MOUSEINPUT 的 ULONG_PTR 位宽,x64 下 type 后
|
|
724
|
+
* 自动补 4B padding 使 union 8 对齐(MSVC 布局)。HARDWAREINPUT 不注入,省略不改
|
|
725
|
+
* 尺寸(union 尺寸 = max 成员 = MOUSEINPUT)。dwExtraInfo 是 ULONG_PTR 信息位(非句柄)
|
|
726
|
+
* → <>ptr 裸档(uintptr 双态先例:WPARAM/LPARAM/void*),恒传 0 */
|
|
727
|
+
export const INPUT_DECL = {
|
|
728
|
+
'#': 'struct',
|
|
729
|
+
type: 'u32',
|
|
730
|
+
data: {
|
|
731
|
+
'#': 'union',
|
|
732
|
+
mi: MOUSEINPUT_DECL,
|
|
733
|
+
ki: KEYBDINPUT_DECL,
|
|
734
|
+
} satisfies C_Union,
|
|
735
|
+
} satisfies C_Struct
|
|
736
|
+
|
|
737
|
+
export const INPUT = /* @__PURE__ */ struct('INPUT', INPUT_DECL)
|
|
738
|
+
|
|
739
|
+
/** NOTIFYICONIDENTIFIER(Shell_NotifyIconGetRect 定位托盘通知图标;x86 28B / x64 40B——
|
|
740
|
+
* hWnd 是 HWND 随位宽,guidItem = GUID 固定 16B 不随)。定位二法取一:guidItem 非全 0
|
|
741
|
+
* 时忽略 hWnd/uID,否则走 hWnd+uID(deskmon 等自注册图标即此形,与 Shell_NotifyIcon
|
|
742
|
+
* 的 {hwnd,uID} 同源);guidItem 缺省 = GUID_NULL 走 hWnd+uID。cbSize 调用前填
|
|
743
|
+
* NOTIFYICONIDENTIFIER.size(cb 结构惯例,见 PROCESS_MEMORY_COUNTERS 同) */
|
|
744
|
+
export const NOTIFYICONIDENTIFIER_DECL = {
|
|
745
|
+
'#': 'struct',
|
|
746
|
+
cbSize: 'u32',
|
|
747
|
+
hWnd: '<HWND>ptr',
|
|
748
|
+
uID: 'u32',
|
|
749
|
+
guidItem: 'u32[4]',
|
|
750
|
+
} satisfies C_Struct
|
|
751
|
+
|
|
752
|
+
export const NOTIFYICONIDENTIFIER = /* @__PURE__ */ struct('NOTIFYICONIDENTIFIER', NOTIFYICONIDENTIFIER_DECL)
|
package/lib/windows/user32.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// user32.dll 精选高频 API(
|
|
1
|
+
// user32.dll 精选高频 API(99 个),逐函数独立导出:
|
|
2
2
|
// - 签名对照 mingw winuser.h 原型手写;未被 import 的绑定经 esbuild 摇树不进产物
|
|
3
3
|
// - WPARAM / LPARAM / LRESULT / UINT_PTR / LONG_PTR 及句柄混合值一律 <>ptr(指针宽度跨
|
|
4
4
|
// 架构正确;返回值 0 保真(C→JS 不做 0→null)、有符号读对齐 C 版 JS_NewInt64——-1 哨兵等负值保真)
|
|
@@ -24,8 +24,9 @@
|
|
|
24
24
|
// <HGLOBAL>ptr 自产自收)
|
|
25
25
|
import * as os from 'os';
|
|
26
26
|
import { bind } from '../ffi/bind.js';
|
|
27
|
+
import { structArray } from '../ffi/struct.js';
|
|
27
28
|
// 只 import 注册了 encoder 的结构(纯入参位);POINT 等出/就地位不注册,运行时无需引用
|
|
28
|
-
import { MSG, RECT, SCROLLINFO, WNDCLASSEXW } from './structs.js';
|
|
29
|
+
import { INPUT, MSG, RECT, SCROLLINFO, WNDCLASSEXW } from './structs.js';
|
|
29
30
|
// dll 名部分应用:85 个绑定共用,签名字符串不再重复 'user32.dll'。
|
|
30
31
|
// 不能用 bind.bind(null, dll)——泛型在部分应用点坍缩(返回 never);工厂转调让
|
|
31
32
|
// S/LE/LD 在调用点正常 infer。第三参透传 encoders(结构入参位注册,见头注释方向约定)。
|
|
@@ -43,7 +44,7 @@ const LONG_PTR_SYM = os.arch === 'x64' ? 'PtrW' : 'W';
|
|
|
43
44
|
* @param args_0 dwExStyle WS_EX_*
|
|
44
45
|
* @param args_1 lpClassName 窗口类名 string 或 NULL
|
|
45
46
|
* @param args_2 lpWindowName 窗口标题 string 或 NULL
|
|
46
|
-
* @param args_3 dwStyle WS_*(
|
|
47
|
+
* @param args_3 dwStyle WS_*(WindowStyle 类常量)
|
|
47
48
|
* @param args_4 x 初始左上角(CW_USEDEFAULT = -1)
|
|
48
49
|
* @param args_5 y 初始左上角(CW_USEDEFAULT = -1)
|
|
49
50
|
* @param args_6 nWidth
|
|
@@ -57,7 +58,7 @@ export const CreateWindowEx = /*@__PURE__*/ b('CreateWindowExW', 'u32 <WCHAR>ptr
|
|
|
57
58
|
* @returns 成功 → 非 0
|
|
58
59
|
* @param args_0 hWnd */
|
|
59
60
|
export const DestroyWindow = /*@__PURE__*/ b('DestroyWindow', '<HWND>ptr -> i32');
|
|
60
|
-
/** 显示/隐藏窗口(nCmdShow =
|
|
61
|
+
/** 显示/隐藏窗口(nCmdShow = WindowStyle 类常量)
|
|
61
62
|
* @returns 先前可见性
|
|
62
63
|
* @param args_0 hWnd
|
|
63
64
|
* @param args_1 nCmdShow 显示命令(SW_SHOW/SW_HIDE 等) */
|
|
@@ -300,7 +301,7 @@ export const EndPaint = /*@__PURE__*/ b('EndPaint', '<HWND>ptr <PAINTSTRUCT>ptr
|
|
|
300
301
|
* @param args_1 lpchText 文本 string(自动 UTF-16 编码)
|
|
301
302
|
* @param args_2 cchText 字符数(-1 = 自动算到 NUL)
|
|
302
303
|
* @param args_3 lpRect 矩形(双向不注册 encoder;CALCRECT 就地写回:RECT.encode(初值) 传 .ptr、decode 读回)
|
|
303
|
-
* @param args_4 uFormat DT_* 排版标志(
|
|
304
|
+
* @param args_4 uFormat DT_* 排版标志(DrawTextFlag) */
|
|
304
305
|
export const DrawText = /*@__PURE__*/ b('DrawTextW', '<HDC>ptr! <WCHAR>ptr i32 <RECT>ptr i32 -> i32');
|
|
305
306
|
/** 用画刷填充矩形
|
|
306
307
|
* @returns 填充高度
|
|
@@ -394,6 +395,17 @@ export const GetKeyboardState = /*@__PURE__*/ b('GetKeyboardState', '<BYTE>ptr -
|
|
|
394
395
|
* @returns SHORT(低字节 VK、高位 shift/ctrl/alt 掩码),无 → -1
|
|
395
396
|
* @param args_0 ch 字符码(如 65 = 'A') */
|
|
396
397
|
export const VkKeyScan = /*@__PURE__*/ b('VkKeyScanW', 'u32 -> i32');
|
|
398
|
+
// INPUT 数组 encoder(SendInput 的 <INPUT>ptr 位注册后值域即元素数组——与 gdi32
|
|
399
|
+
// POINTArr 同机制,token/引擎层零数组概念)
|
|
400
|
+
const INPUTArr = /*@__PURE__*/ structArray(INPUT);
|
|
401
|
+
/** 批量注入输入事件(一次调用 = cInputs 个 INPUT 紧密数组 = 一个原子输入块)
|
|
402
|
+
* @returns 成功注入的事件数;0 = 全部失败(UIPI:目标进程完整性更高),< cInputs = 部分成功
|
|
403
|
+
* @param args_0 events INPUT 元素数组(structArray(INPUT) encoder 直传
|
|
404
|
+
* [{type:0|1, data:{mi|ki:{...}}}];绝对坐标 dx/dy 是 0-65535 归一化物理像素——本引擎
|
|
405
|
+
* SetProcessDPIAware,GetSystemMetrics/GetWindowRect 同空间,换算 x*65535/(SM_CXSCREEN-1))
|
|
406
|
+
* @param args_1 cbSize 传 INPUT.size(MSDN 要求 = sizeof(INPUT),x86 28 / x64 40,
|
|
407
|
+
* 传错整体静默失败) */
|
|
408
|
+
export const SendInput = /*@__PURE__*/ b('SendInput', 'u32 <INPUT>ptr i32 -> u32', { INPUT: INPUTArr });
|
|
397
409
|
// ============ 计时器 ============
|
|
398
410
|
/** 设定时器(hWnd/id 传 NULL/0 = 自动分配 id;lpTimerFunc 传 NULL 用 WM_TIMER)
|
|
399
411
|
* @returns 定时器 ID(自动分配时从返回值读回);失败 → 0
|
|
@@ -520,7 +532,7 @@ export const ShowScrollBar = /*@__PURE__*/ b('ShowScrollBar', '<HWND>ptr u32 i32
|
|
|
520
532
|
* @param args_3 uType MB_* 样式(MB_OK/MB_YESNO 等) */
|
|
521
533
|
export const MessageBox = /*@__PURE__*/ b('MessageBoxW', '<HWND>ptr <WCHAR>ptr <WCHAR>ptr u32 -> i32');
|
|
522
534
|
// ============ 图像 ============
|
|
523
|
-
/** 按名加载图像(string 自动编码;uType/fuLoad 用 Win32 真值——与
|
|
535
|
+
/** 按名加载图像(string 自动编码;uType/fuLoad 用 Win32 真值——与 ImageType 枚举当前值
|
|
524
536
|
* 不同)
|
|
525
537
|
* @returns 图像句柄;失败 → 0
|
|
526
538
|
* @param args_0 hinst 模块句柄,NULL = 系统资源或 .ico 文件
|
package/lib/windows/user32.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// user32.dll 精选高频 API(
|
|
1
|
+
// user32.dll 精选高频 API(99 个),逐函数独立导出:
|
|
2
2
|
// - 签名对照 mingw winuser.h 原型手写;未被 import 的绑定经 esbuild 摇树不进产物
|
|
3
3
|
// - WPARAM / LPARAM / LRESULT / UINT_PTR / LONG_PTR 及句柄混合值一律 <>ptr(指针宽度跨
|
|
4
4
|
// 架构正确;返回值 0 保真(C→JS 不做 0→null)、有符号读对齐 C 版 JS_NewInt64——-1 哨兵等负值保真)
|
|
@@ -24,8 +24,9 @@
|
|
|
24
24
|
// <HGLOBAL>ptr 自产自收)
|
|
25
25
|
import * as os from 'os'
|
|
26
26
|
import { bind, type CodecMap } from '../ffi/bind.js'
|
|
27
|
+
import { structArray } from '../ffi/struct.js'
|
|
27
28
|
// 只 import 注册了 encoder 的结构(纯入参位);POINT 等出/就地位不注册,运行时无需引用
|
|
28
|
-
import { MSG, RECT, SCROLLINFO, WNDCLASSEXW } from './structs.js'
|
|
29
|
+
import { INPUT, MSG, RECT, SCROLLINFO, WNDCLASSEXW } from './structs.js'
|
|
29
30
|
|
|
30
31
|
// dll 名部分应用:85 个绑定共用,签名字符串不再重复 'user32.dll'。
|
|
31
32
|
// 不能用 bind.bind(null, dll)——泛型在部分应用点坍缩(返回 never);工厂转调让
|
|
@@ -48,7 +49,7 @@ const LONG_PTR_SYM = os.arch === 'x64' ? 'PtrW' : 'W'
|
|
|
48
49
|
* @param args_0 dwExStyle WS_EX_*
|
|
49
50
|
* @param args_1 lpClassName 窗口类名 string 或 NULL
|
|
50
51
|
* @param args_2 lpWindowName 窗口标题 string 或 NULL
|
|
51
|
-
* @param args_3 dwStyle WS_*(
|
|
52
|
+
* @param args_3 dwStyle WS_*(WindowStyle 类常量)
|
|
52
53
|
* @param args_4 x 初始左上角(CW_USEDEFAULT = -1)
|
|
53
54
|
* @param args_5 y 初始左上角(CW_USEDEFAULT = -1)
|
|
54
55
|
* @param args_6 nWidth
|
|
@@ -63,7 +64,7 @@ export const CreateWindowEx = /*@__PURE__*/ b('CreateWindowExW',
|
|
|
63
64
|
* @returns 成功 → 非 0
|
|
64
65
|
* @param args_0 hWnd */
|
|
65
66
|
export const DestroyWindow = /*@__PURE__*/ b('DestroyWindow', '<HWND>ptr -> i32')
|
|
66
|
-
/** 显示/隐藏窗口(nCmdShow =
|
|
67
|
+
/** 显示/隐藏窗口(nCmdShow = WindowStyle 类常量)
|
|
67
68
|
* @returns 先前可见性
|
|
68
69
|
* @param args_0 hWnd
|
|
69
70
|
* @param args_1 nCmdShow 显示命令(SW_SHOW/SW_HIDE 等) */
|
|
@@ -313,7 +314,7 @@ export const EndPaint = /*@__PURE__*/ b('EndPaint', '<HWND>ptr <PAINTSTRUCT>ptr
|
|
|
313
314
|
* @param args_1 lpchText 文本 string(自动 UTF-16 编码)
|
|
314
315
|
* @param args_2 cchText 字符数(-1 = 自动算到 NUL)
|
|
315
316
|
* @param args_3 lpRect 矩形(双向不注册 encoder;CALCRECT 就地写回:RECT.encode(初值) 传 .ptr、decode 读回)
|
|
316
|
-
* @param args_4 uFormat DT_* 排版标志(
|
|
317
|
+
* @param args_4 uFormat DT_* 排版标志(DrawTextFlag) */
|
|
317
318
|
export const DrawText = /*@__PURE__*/ b('DrawTextW', '<HDC>ptr! <WCHAR>ptr i32 <RECT>ptr i32 -> i32')
|
|
318
319
|
/** 用画刷填充矩形
|
|
319
320
|
* @returns 填充高度
|
|
@@ -413,6 +414,17 @@ export const GetKeyboardState = /*@__PURE__*/ b('GetKeyboardState', '<BYTE>ptr -
|
|
|
413
414
|
* @returns SHORT(低字节 VK、高位 shift/ctrl/alt 掩码),无 → -1
|
|
414
415
|
* @param args_0 ch 字符码(如 65 = 'A') */
|
|
415
416
|
export const VkKeyScan = /*@__PURE__*/ b('VkKeyScanW', 'u32 -> i32')
|
|
417
|
+
// INPUT 数组 encoder(SendInput 的 <INPUT>ptr 位注册后值域即元素数组——与 gdi32
|
|
418
|
+
// POINTArr 同机制,token/引擎层零数组概念)
|
|
419
|
+
const INPUTArr = /*@__PURE__*/ structArray(INPUT)
|
|
420
|
+
/** 批量注入输入事件(一次调用 = cInputs 个 INPUT 紧密数组 = 一个原子输入块)
|
|
421
|
+
* @returns 成功注入的事件数;0 = 全部失败(UIPI:目标进程完整性更高),< cInputs = 部分成功
|
|
422
|
+
* @param args_0 events INPUT 元素数组(structArray(INPUT) encoder 直传
|
|
423
|
+
* [{type:0|1, data:{mi|ki:{...}}}];绝对坐标 dx/dy 是 0-65535 归一化物理像素——本引擎
|
|
424
|
+
* SetProcessDPIAware,GetSystemMetrics/GetWindowRect 同空间,换算 x*65535/(SM_CXSCREEN-1))
|
|
425
|
+
* @param args_1 cbSize 传 INPUT.size(MSDN 要求 = sizeof(INPUT),x86 28 / x64 40,
|
|
426
|
+
* 传错整体静默失败) */
|
|
427
|
+
export const SendInput = /*@__PURE__*/ b('SendInput', 'u32 <INPUT>ptr i32 -> u32', { INPUT: INPUTArr })
|
|
416
428
|
|
|
417
429
|
// ============ 计时器 ============
|
|
418
430
|
|
|
@@ -551,7 +563,7 @@ export const MessageBox = /*@__PURE__*/ b('MessageBoxW', '<HWND>ptr <WCHAR>ptr <
|
|
|
551
563
|
|
|
552
564
|
// ============ 图像 ============
|
|
553
565
|
|
|
554
|
-
/** 按名加载图像(string 自动编码;uType/fuLoad 用 Win32 真值——与
|
|
566
|
+
/** 按名加载图像(string 自动编码;uType/fuLoad 用 Win32 真值——与 ImageType 枚举当前值
|
|
555
567
|
* 不同)
|
|
556
568
|
* @returns 图像句柄;失败 → 0
|
|
557
569
|
* @param args_0 hinst 模块句柄,NULL = 系统资源或 .ico 文件
|
package/lib/windows/winspool.js
CHANGED
|
@@ -14,7 +14,7 @@ const b = (name, sig, encoders) => bind('winspool.drv', name, sig, encoders);
|
|
|
14
14
|
/** 枚举打印队列(Level=2 → PRINTER_INFO_2W 数组);两段式:先
|
|
15
15
|
* NULL+cbBuf 0 拿 pcbNeeded,再按需分配缓冲重调
|
|
16
16
|
* @returns 成功 → 非 0
|
|
17
|
-
* @param args_0 dwFlags 枚举范围:
|
|
17
|
+
* @param args_0 dwFlags 枚举范围:PrinterEnum.LOCAL(0x2) 本地 | CONNECTIONS(0x4)
|
|
18
18
|
* 已连接,组合 OR 传裸数(可组合 flags 不标枚举)
|
|
19
19
|
* @param args_1 pName 服务器名(仅 Level=4/5/6 用),本地枚举传 NULL
|
|
20
20
|
* @param args_2 dwLevel 信息级别,取 2(PRINTER_INFO_2W)
|
|
@@ -28,12 +28,12 @@ export const EnumPrinters = /*@__PURE__*/ b('EnumPrintersW', 'u32 <WCHAR>ptr u32
|
|
|
28
28
|
* @param args_0 pszBuffer 出参缓冲,WCHAR.alloc(n)、WCHAR.decode 读回
|
|
29
29
|
* @param args_1 pcchBuffer 出入长度槽(入 = 缓冲 WCHAR 容量,出 = 实际长度),PtrArrayBuffer(4) */
|
|
30
30
|
export const GetDefaultPrinter = /*@__PURE__*/ b('GetDefaultPrinterW', '<BYTE>ptr <BYTE>ptr -> i32');
|
|
31
|
-
/** 查设备能力;nCapability 单选
|
|
31
|
+
/** 查设备能力;nCapability 单选 DeviceCap.*
|
|
32
32
|
* @returns 返回值随能力(数值能力 = 数值,
|
|
33
33
|
* -1 = 失败)
|
|
34
34
|
* @param args_0 pDevice 打印机名(禁空)
|
|
35
35
|
* @param args_1 pPort 端口名,传 NULL 用打印机配置端口
|
|
36
|
-
* @param args_2 nCapability 能力码(
|
|
36
|
+
* @param args_2 nCapability 能力码(DeviceCap.HORZRES 等单选)
|
|
37
37
|
* @param args_3 pOutput 字符串列表型能力的缓冲;数值型查询传 NULL
|
|
38
38
|
* @param args_4 pDevmode DEVMODE,传 NULL */
|
|
39
39
|
export const DeviceCapabilities = /*@__PURE__*/ b('DeviceCapabilitiesW', '<WCHAR>ptr! <WCHAR>ptr u32@DeviceCap <BYTE>ptr <>ptr -> i32');
|
package/lib/windows/winspool.ts
CHANGED
|
@@ -17,7 +17,7 @@ const b = <const S extends string, const LE extends CodecMap = {}>(name: string,
|
|
|
17
17
|
/** 枚举打印队列(Level=2 → PRINTER_INFO_2W 数组);两段式:先
|
|
18
18
|
* NULL+cbBuf 0 拿 pcbNeeded,再按需分配缓冲重调
|
|
19
19
|
* @returns 成功 → 非 0
|
|
20
|
-
* @param args_0 dwFlags 枚举范围:
|
|
20
|
+
* @param args_0 dwFlags 枚举范围:PrinterEnum.LOCAL(0x2) 本地 | CONNECTIONS(0x4)
|
|
21
21
|
* 已连接,组合 OR 传裸数(可组合 flags 不标枚举)
|
|
22
22
|
* @param args_1 pName 服务器名(仅 Level=4/5/6 用),本地枚举传 NULL
|
|
23
23
|
* @param args_2 dwLevel 信息级别,取 2(PRINTER_INFO_2W)
|
|
@@ -34,12 +34,12 @@ export const EnumPrinters = /*@__PURE__*/ b('EnumPrintersW',
|
|
|
34
34
|
* @param args_1 pcchBuffer 出入长度槽(入 = 缓冲 WCHAR 容量,出 = 实际长度),PtrArrayBuffer(4) */
|
|
35
35
|
export const GetDefaultPrinter = /*@__PURE__*/ b('GetDefaultPrinterW', '<BYTE>ptr <BYTE>ptr -> i32')
|
|
36
36
|
|
|
37
|
-
/** 查设备能力;nCapability 单选
|
|
37
|
+
/** 查设备能力;nCapability 单选 DeviceCap.*
|
|
38
38
|
* @returns 返回值随能力(数值能力 = 数值,
|
|
39
39
|
* -1 = 失败)
|
|
40
40
|
* @param args_0 pDevice 打印机名(禁空)
|
|
41
41
|
* @param args_1 pPort 端口名,传 NULL 用打印机配置端口
|
|
42
|
-
* @param args_2 nCapability 能力码(
|
|
42
|
+
* @param args_2 nCapability 能力码(DeviceCap.HORZRES 等单选)
|
|
43
43
|
* @param args_3 pOutput 字符串列表型能力的缓冲;数值型查询传 NULL
|
|
44
44
|
* @param args_4 pDevmode DEVMODE,传 NULL */
|
|
45
45
|
export const DeviceCapabilities = /*@__PURE__*/ b('DeviceCapabilitiesW',
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "quickwin",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.3.1",
|
|
5
5
|
"description": "QuickJS Win32 runtime — GUI, networking, WASM, FFI, and more",
|
|
6
6
|
"bin": {
|
|
7
7
|
"quickwin": "qwin.exe",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"examples/",
|
|
25
25
|
"vendor/",
|
|
26
26
|
"quickwin.d.ts",
|
|
27
|
-
"
|
|
27
|
+
"constants.ts",
|
|
28
|
+
"enum_map.d.ts",
|
|
28
29
|
"tsconfig.json",
|
|
29
30
|
"README.md",
|
|
30
31
|
"README.en.md"
|
|
@@ -32,7 +33,7 @@
|
|
|
32
33
|
"license": "MIT",
|
|
33
34
|
"repository": {
|
|
34
35
|
"type": "git",
|
|
35
|
-
"url": "git+https://github.com/
|
|
36
|
+
"url": "git+https://github.com/quickwinlabs/quickwin.git"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"@types/node": "^24.13.2",
|