forked from kihlh/hmc-win32
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhmc2.d.ts
353 lines (353 loc) · 12.1 KB
/
hmc2.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
/// <reference types="node" />
import { HMC } from "./hmc";
import { HWND } from "./hmc";
export declare module HMCC {
type CLIP_HTML_INFO = {
data: string;
EndFragment: number;
EndHTML: number;
is_valid: boolean;
SourceURL: string;
StartFragment: number;
StartHTML: number;
Version: number;
};
enum FS_MK_LINK_TARGET_TYPE {
CREATE_DIR_SYMLINK = 166,
CREATE_SYMLINK = 168,
CREATE_HARD_LINK = 170,
CREATE_SYMBOLIC_LINK = 172
}
}
export type HMCC = {
/**
* 关闭窗口 同步
* @param handle 句柄
* @param grade 等级
* - 1 关闭 / 非强制
* - 2 关闭 / 系统级(半强制)
* - 3 关闭线程 (强制)
*/
closeWindow2?: (handle: number, grade: 1 | 2 | 3) => Promise<boolean>;
/**
* 关闭窗口 同步
* @param handle 句柄
* @param grade 等级
* - 1 关闭 / 非强制
* - 2 关闭 / 系统级(半强制)
* - 3 关闭线程 (强制)
*/
closeWindow2Sync?: (handle: number, grade: 1 | 2 | 3) => boolean;
captureBmpToBuff?: (x: number, y: number, nScopeWidth: number, nScopeHeight: number) => null | Buffer;
captureBmpToFile?: (path: string, x: number, y: number, nScopeWidth: number, nScopeHeight: number) => undefined;
captureBmp2?: HMCC.CaptureBmp;
captureBmp2Sync?: HMCC.CaptureBmpSync;
getClipboardFilePaths?: () => string;
setClipboardText?: (text: string, is_html?: boolean) => boolean;
getClipboardText?: () => string | null;
clearClipboard?: () => boolean;
setClipboardFilePaths?: (paths: string | string[]) => boolean;
getClipboardInfo?: () => {
format: string;
hwnd: number;
id: number;
formatCount: number;
};
enumClipboardFormats?: () => `{"type":${string},"type_name":${string}}...[]`;
/**
* 获取剪贴板中的html
*/
getClipboardHTML?: () => HMCC.CLIP_HTML_INFO | null;
/**
* 获取托盘图标列表
* ? win11 在22621.1000版本之后失效 具体原因查看https://github.com/kihlh/hmc-win32/issues/36
*/
getTrayList?: () => string;
/**
* 删除文件到垃圾桶
* @param trash_path 处理的路径
* @param is_Recycle 可以回收
* @param isShow 显示窗口
*/
trashFile?: (trash_path: string, is_Recycle: boolean, isShow: boolean) => boolean;
/**
* 清空回收站
* @param root_path 文件或者根目录
* @param isShow 是否显示窗口
*/
clearTrash?: (root_path: string, isShow: boolean) => boolean;
/**
*
* @param filePath
* @param newFilePath
* @param isShowConfirm
* @param isShow
* @param isShowProgress
* @param trash_ok
* @returns
*/
copyFile?: (filePath: string, newFilePath: string, isShowConfirm: boolean, isShow: boolean, isShowProgress: boolean, trash_ok: boolean) => boolean;
/**
*
* @param filePath
* @param newFilePath
* @param isShowConfirm
* @param isShow
* @param isShowProgress
* @param trash_ok
* @returns
*/
moveFile?: (filePath: string, newFilePath: string, isShowConfirm: boolean, isShow: boolean, isShowProgress: boolean, trash_ok: boolean) => boolean;
getThumbnailPng?: (...args: unknown[]) => unknown;
/**
* 获取 软/硬 链接的指向内容
* @param Linkath
*/
getLinkTarget?: (Linkath: string) => string | string[] | null;
/**
* 设置文件夹的缩略图
* @param folderPath 路径
* @param iconPath 图标路径
* @param iconIndex 图标索引 比如exe中的0
* @returns
*/
setFolderIcon?: (folderPath: string, iconPath: string, iconIndex?: number) => boolean;
/**
* 判断指定文件是否是 软链接/硬链接
* @param path
* @returns
*/
isLinkLink?: (path: string) => boolean;
/**
* 创建 软链接/硬链接/目录连接点/文件夹链接
* @param targetType 创建类型
* - 文件夹链接 CREATE_DIR_SYMLINK = 166
* - 软链接 CREATE_SYMLINK = 168
* - 硬链接 CREATE_HARD_LINK = 170
* - 目录连接点 CREATE_SYMBOLIC_LINK = 172
* @param targetPath 目标位置
* @param sourcePath 源文件路径
* @returns
*/
createFsLink?: (targetType: HMCC.FS_MK_LINK_TARGET_TYPE, targetPath: string, sourcePath: string) => boolean;
/**
* 弹出右键菜单的接口
* @param hwnd 调用窗口 / 允许为null
* @param file 指定需要被显示菜单的文件/文件夹/文件列表/ 为空 "" 为驱动器
* @param x 坐标 x+y=0的时候将会从鼠标所在的地方显示
* @param y 坐标
*/
showContextMenu?: (hwnd: number | null, file: string | string[], x: number, y: number) => boolean;
};
export declare module HMCC {
interface CaptureBmp {
(handle: number): Promise<Buffer | null>;
(handle: number, path: string): Promise<boolean>;
(path: string): Promise<boolean>;
(): Promise<Buffer | null>;
(x: number, y: number, nScopeWidth: number, nScopeHeight: number): Promise<Buffer | null>;
(path: string, x: number, y: number, nScopeWidth: number, nScopeHeight: number): Promise<boolean>;
}
interface CaptureBmpSync {
(handle: number): Buffer | null;
(handle: number, path: string): boolean;
(path: string): boolean;
(): Buffer | null;
(x: number, y: number, nScopeWidth: number, nScopeHeight: number): Buffer | null;
(path: string, x: number, y: number, nScopeWidth: number, nScopeHeight: number): boolean;
}
}
export declare const native2: HMCC;
declare class AsyncFunctionTaskQueue {
queues: Map<(...args: any[]) => Promise<any>, any>;
constructor();
runTask<T>(fn: (...args: any[]) => Promise<T>, ...args: any[]): Promise<T>;
next<T>(fn: (...args: any[]) => Promise<T>): Promise<void>;
}
export declare const asyncTaskQueue: AsyncFunctionTaskQueue;
/**
* 关闭窗口 异步
* - 1 温柔的关闭 (正常关闭)
* - 2 关闭 / 系统级(半强制)
* - 3 关闭线程 (强制)
*/
export declare function closeWindow2(handle: number | HWND, grade?: 1 | 2 | 3): Promise<boolean>;
/**
* [同步 不支持并发] 关闭窗口
* - 1 温柔的关闭 (正常关闭)
* - 2 关闭 / 系统级(半强制)
* - 3 关闭线程 (强制)
*/
export declare function closeWindow2Sync(handle: number | HWND, grade?: 1 | 2 | 3): boolean;
/**
* 获取文件缩略图
* @param source 文件
* @param output 保存到
* @param img_size 要求尺寸 建议为:
* - 16
* - 32
* - 64
* - 128
* - 256
*/
export declare function getThumbnailPng(source: string, output: string, img_size: 16 | 64 | 128 | 256): boolean;
/**
* 获取文件缩略图
* @param source 文件
* @param img_size 要求尺寸 建议为:
* - 16
* - 32
* - 64
* - 128
* - 256
*/
export declare function getThumbnailPng(source: string, img_size: 16 | 64 | 128 | 256): Buffer | null;
export declare function getThumbnailPng(...args: unknown[]): unknown;
/**
* 截图bmp到缓冲区
* @param x 起点
* @param y 起点
* @param nScopeWidth 矩形宽
* @param nScopeHeight 矩形高
* @returns
*/
export declare function captureBmpToBuff(x?: number, y?: number, nScopeWidth?: number, nScopeHeight?: number): Buffer | null;
/**
* 截图bmp到文件
* @param x 起点
* @param y 起点
* @param nScopeWidth 矩形宽
* @param nScopeHeight 矩形高
* @returns
*/
export declare function captureBmpToFile(path: string, x?: number, y?: number, nScopeWidth?: number, nScopeHeight?: number): undefined;
/**
* 弹出右键菜单的接口
* @param hwnd 调用窗口 / 允许为null
* @param file 指定需要被显示菜单的文件/文件夹/文件列表/ 为空 "" 为驱动器
* @param x 坐标 x+y=0的时候将会从鼠标所在的地方显示
* @param y 坐标
*/
export declare function showContextMenu(hwnd?: number | null, file?: string | string[], x?: number, y?: number): boolean;
/**
* 将 electron 句柄内存缓冲区转换为标准 窗口数字句柄
* @param handleBuffer 例如 Electron.BrowserWindow.getFocusedWindow().getNativeWindowHandle()
* @returns
*/
export declare function readElectronHandle(handleBuffer: any): number;
/**
* 获取剪贴板文件路径列表 以\0切割
* @returns
*/
export declare function getClipboardFilePaths(): string[];
/**
* 设置剪贴板本文或者html
* @param text
* @param is_html
* @returns
*/
export declare function setClipboardText(text: string, is_html?: boolean): boolean;
/**
* 获取剪贴板文本
* @returns
*/
export declare function getClipboardText(): string | null;
/**
* 清空剪贴板
* @returns
*/
export declare function clearClipboard(): boolean;
/**
* 设置文件路径列表
* @param paths 支持以 \0 切割的路径或者单文件路径 或者数组
*/
export declare function setClipboardFilePaths(paths: string | string[]): boolean;
/**
* 获取托盘图标列表
* 1.4.6 起返回json文本
* ? win11 在22621.1000版本之后失效 具体原因查看https://github.com/kihlh/hmc-win32/issues/36
*/
export declare function getTrayList(): Array<HMC.TRAY_ICON>;
/**
* 设置文件夹的缩略图
* @param folderPath 路径
* @param iconPath 图标路径
* @param iconIndex 图标索引 比如exe中的0
* @returns
*/
export declare function setFolderIcon(folderPath: string, iconPath: string, iconIndex?: number): boolean;
/**
* 截图主屏幕为bmp缓冲区 [异步]
*/
export declare function captureBmp2(): Promise<Buffer | null>;
/**
* 截图窗口句柄区域为bmp缓冲区 [异步]
* @param handle 句柄
*/
export declare function captureBmp2(handle: number | HWND): Promise<Buffer | null>;
/**
* 截图主屏幕到文件中 [异步]
* @param path 文件路径
*/
export declare function captureBmp2(path: string): Promise<boolean>;
/**
* 截图窗口句柄区域为文件 [异步]
* ? 不会提前将窗口前置 因此会包含其他信息
* @param handle 句柄
* @param path 文件路径
*/
export declare function captureBmp2(handle: number | HWND, path: string): Promise<boolean>;
/**
* 截图主屏幕为bmp缓冲区 [异步]
* @param x (x) 从屏幕左边到所在位置得像素数
* @param y (y) 从屏幕顶部边到所在位置得像素数
* @param nScopeWidth 要求宽度
* @param nScopeHeight 要求高度
*/
export declare function captureBmp2(x: number, y: number, nScopeWidth: number, nScopeHeight: number): Promise<Buffer | null>;
/**
* 截图主屏幕为bmp文件 [异步]
* @param x (x) 从屏幕左边到所在位置得像素数
* @param y (y) 从屏幕顶部边到所在位置得像素数
* @param nScopeWidth 要求宽度
* @param nScopeHeight 要求高度
*/
export declare function captureBmp2(path: string, x: number, y: number, nScopeWidth: number, nScopeHeight: number): Promise<boolean>;
/**
* 截图主屏幕为bmp缓冲区 [同步]
*/
export declare function captureBmp2Sync(): Buffer | null;
/**
* 截图窗口句柄区域为bmp缓冲区 [同步]
* @param handle 句柄
*/
export declare function captureBmp2Sync(handle: number | HWND): Buffer | null;
/**
* 截图主屏幕到文件中 [同步]
* @param path 文件路径
*/
export declare function captureBmp2Sync(path: string): boolean;
/**
* 截图窗口句柄区域为文件 [同步]
* ? 不会提前将窗口前置 因此会包含其他信息
* @param handle 句柄
* @param path 文件路径
*/
export declare function captureBmp2Sync(handle: number | HWND, path: string): boolean;
/**
* 截图主屏幕为bmp缓冲区 [同步]
* @param x (x) 从屏幕左边到所在位置得像素数
* @param y (y) 从屏幕顶部边到所在位置得像素数
* @param nScopeWidth 要求宽度
* @param nScopeHeight 要求高度
*/
export declare function captureBmp2Sync(x: number, y: number, nScopeWidth: number, nScopeHeight: number): Buffer | null;
/**
* 截图主屏幕为bmp文件 [同步]
* @param x (x) 从屏幕左边到所在位置得像素数
* @param y (y) 从屏幕顶部边到所在位置得像素数
* @param nScopeWidth 要求宽度
* @param nScopeHeight 要求高度
*/
export declare function captureBmp2Sync(path: string, x: number, y: number, nScopeWidth: number, nScopeHeight: number): boolean;
export {};