ms-types 0.0.8 → 0.0.10

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.
@@ -0,0 +1,205 @@
1
+ declare namespace image {
2
+ /**
3
+ * 截图
4
+ * @returns 截图的imageId ,如果截图失败则返回null
5
+ */
6
+ function captureFullScreen(): string | null;
7
+ /**
8
+ * 保存图片
9
+ * @param imageId 图片id 路径 http地址或者 screen 实时截屏
10
+ * @param filePath 保存路径
11
+ */
12
+ function saveTo(imageId: string, filePath: string): void;
13
+ /**
14
+ * 图片是否已释放
15
+ * @param imageId 图片id
16
+ * @returns true 已释放 false 未释放
17
+ */
18
+ function isRelease(imageId: string): boolean;
19
+ /**
20
+ * 释放图片
21
+ * @param imageId 图片id
22
+ */
23
+ function release(imageId: string): void;
24
+ /**
25
+ * 释放所有图片
26
+ */
27
+ function releaseAll(): void;
28
+ /**
29
+ * 获取图片大小
30
+ * @param imageId 图片id
31
+ * @returns 图片大小 {width: number, height: number}
32
+ */
33
+ function getSize(imageId: string): { width: number; height: number } | null;
34
+ /**
35
+ * 读取图片
36
+ * @param path 图片路径
37
+ * @returns 图片id ,如果读取失败则返回null
38
+ */
39
+ function readImage(path: string): string | null;
40
+ /**
41
+ * 旋转图片
42
+ * @param imageId 图片id
43
+ * @param degree 旋转角度 只能是 90 -90 180
44
+ * @returns 旋转后的图片id ,如果旋转失败则返回null
45
+ */
46
+ function rotateImage(imageId: string, degree: number): string | null;
47
+ /**
48
+ * 比较颜色
49
+ * @param imageId 图片id
50
+ * @param points 颜色点
51
+ * @param threshold 阈值
52
+ * @param x 左上角x
53
+ * @param y 左上角y
54
+ * @param ex 右下角x
55
+ * @param ey 右下角y
56
+ * @returns true 相同 false 不同
57
+ */
58
+ function cmpColor(
59
+ imageId: string,
60
+ points: string,
61
+ threshold: number,
62
+ x: number,
63
+ y: number,
64
+ ex: number,
65
+ ey: number
66
+ ): boolean;
67
+ /**
68
+ * 查找颜色
69
+ * @param imageId 图片id
70
+ * @param color 颜色 支持"主色-偏色"格式,如"0x6DD1E6-0x101010"
71
+ * @param threshold 阈值
72
+ * @param x 左上角x
73
+ * @param y 左上角y
74
+ * @param ex 右下角x
75
+ * @param ey 右下角y
76
+ * @param limit 限制数量
77
+ * @param orz 查找方向1-8
78
+ * @returns 颜色点数组
79
+ */
80
+ function findColor(
81
+ imageId: string,
82
+ color: string,
83
+ threshold: number,
84
+ x: number,
85
+ y: number,
86
+ ex: number,
87
+ ey: number,
88
+ limit: number,
89
+ orz: number
90
+ ): { x: number; y: number }[];
91
+ /**
92
+ * 查找多颜色
93
+ * @param imageId 图片id
94
+ * @param firstColor 第一个颜色
95
+ * @param threshold 阈值
96
+ * @param points 颜色点
97
+ * @param x 左上角x
98
+ * @param y 左上角y
99
+ * @param ex 右下角x
100
+ * @param ey 右下角y
101
+ * @param limit 限制数量
102
+ * @param orz 查找方向1-8
103
+ * @returns 颜色点数组
104
+ */
105
+ function findMultiColor(
106
+ imageId: string,
107
+ firstColor: string,
108
+ threshold: number,
109
+ points: string,
110
+ x: number,
111
+ y: number,
112
+ ex: number,
113
+ ey: number,
114
+ limit: number,
115
+ orz: number
116
+ ): { x: number; y: number }[];
117
+ /**
118
+ * 查找图片
119
+ * @param imageId 图片id
120
+ * @param templateImageId 模板图片id
121
+ * @param x 左上角x
122
+ * @param y 左上角y
123
+ * @param ex 右下角x
124
+ * @param ey 右下角y
125
+ * @param weakThreshold 弱阈值
126
+ * @param limit 限制数量
127
+ * @param method 方法
128
+ * @returns 图片数组
129
+ */
130
+ function findImage(
131
+ imageId: string,
132
+ templateImageId: string,
133
+ x: number,
134
+ y: number,
135
+ ex: number,
136
+ ey: number,
137
+ weakThreshold: number,
138
+ limit: number,
139
+ method: number
140
+ ): {
141
+ x: number;
142
+ y: number;
143
+ width: number;
144
+ height: number;
145
+ confidence: number;
146
+ }[];
147
+ /**
148
+ * 裁剪图片
149
+ * @param imageId 图片id
150
+ * @param x 坐标x
151
+ * @param y 坐标y
152
+ * @param ex 坐标ex
153
+ * @param ey 坐标ey
154
+ * @returns 裁剪后的图片id
155
+ */
156
+ function clip(
157
+ imageId: string,
158
+ x: number,
159
+ y: number,
160
+ ex: number,
161
+ ey: number
162
+ ): string;
163
+ /**
164
+ * 获取图片像素
165
+ * @param imageId 图片id
166
+ * @param x 坐标x
167
+ * @param y 坐标y
168
+ * @returns 颜色值
169
+ */
170
+ function pixel(imageId: string, x: number, y: number): number;
171
+ /**
172
+ * 将整型的颜色值转成16进制RGB字符串
173
+ * @param imageId 图片id
174
+ * @param color 颜色值
175
+ * @returns 16进制RGB字符串
176
+ */
177
+ function argb(imageId: string, color: number): string;
178
+ /**
179
+ * 二值化
180
+ * @param imageId 图片id
181
+ * @param threshold 阈值
182
+ * @returns 二值化后的图片id
183
+ */
184
+ function binaryzation(imageId: string, threshold: number): string;
185
+ /**
186
+ * 灰度化
187
+ * @param imageId 图片id
188
+ * @returns 灰度化后的图片id
189
+ */
190
+ function gray(imageId: string): string;
191
+ /**
192
+ * 图片转base64
193
+ * @param imageId 图片id
194
+ * @returns base64字符串
195
+ */
196
+ function base64ToImage(base64: string): string;
197
+ /**
198
+ * 图片转base64
199
+ * @param imageId 图片id
200
+ * @param format 格式
201
+ * @param q 质量
202
+ * @returns base64字符串
203
+ */
204
+ function toBase64Format(imageId: string, format: string, q: number): string;
205
+ }
package/types/ime.d.ts ADDED
@@ -0,0 +1,59 @@
1
+ declare namespace ime {
2
+ /**
3
+ * 检查输入法是否正常工作 键盘是否显示
4
+ * @returns {boolean} 如果输入法正常工作返回 true,否则返回 false
5
+ */
6
+ function isOk(): boolean;
7
+ /**
8
+ * 获取当前输入框的文本内容
9
+ * @returns {string} 当前输入框的完整文本
10
+ */
11
+ function getText(): string;
12
+ /**
13
+ * 清空当前输入框的文本内容
14
+ */
15
+ function clearText(): boolean;
16
+ /**
17
+ * 模拟输入文本
18
+ * @param {string} text 要输入的文本
19
+ * @returns {string} 输入后的文本内容 失败返回空字符串
20
+ */
21
+ function input(text: string): string;
22
+ /**
23
+ * 模拟粘贴文本
24
+ * @param {string} text 要粘贴的文本
25
+ * @returns {string} 粘贴后的文本内容 失败返回空字符串
26
+ */
27
+ function paste(text: string): string;
28
+ /**
29
+ * 模拟删除键
30
+ * @returns {string} 如果为空,代表输入框无数据,如果不为空,代表输入框剩余数据
31
+ */
32
+ function pressDel(): string;
33
+ /**
34
+ * 模拟回车键
35
+ * @returns {boolean} 如果成功返回 true,否则返回 false
36
+ */
37
+ function pressEnter(): boolean;
38
+ /**
39
+ * 隐藏键盘
40
+ * @returns {boolean} 如果成功返回 true,否则返回 false
41
+ */
42
+ function dismiss(): boolean;
43
+ /**
44
+ * 获取剪贴板内容
45
+ * @returns {string} 剪贴板内容
46
+ */
47
+ function getClipboard(): string;
48
+ /**
49
+ * 设置剪贴板内容
50
+ * @param {string} text 要设置的剪贴板内容 键盘显示时才能设置
51
+ * @returns {boolean} 如果成功返回 true,否则返回 false
52
+ */
53
+ function setClipboard(text: string): boolean;
54
+ /**
55
+ * 切换键盘
56
+ * @returns {boolean} 如果成功返回 true,否则返回 false
57
+ */
58
+ function switchKeyboard(): boolean;
59
+ }
@@ -0,0 +1,17 @@
1
+ /// <reference path="action.d.ts" />
2
+ /// <reference path="config.d.ts" />
3
+ /// <reference path="device.d.ts" />
4
+ /// <reference path="file.d.ts" />
5
+ /// <reference path="global.d.ts" />
6
+ /// <reference path="http.d.ts" />
7
+ /// <reference path="image.d.ts" />
8
+ /// <reference path="ime.d.ts" />
9
+ /// <reference path="logger.d.ts" />
10
+ /// <reference path="media.d.ts" />
11
+ /// <reference path="ocr.d.ts" />
12
+ /// <reference path="system.d.ts" />
13
+ /// <reference path="thread.d.ts" />
14
+ /// <reference path="ui.d.ts" />
15
+ /// <reference path="utils.d.ts" />
16
+ /// <reference path="workerThread.d.ts" />
17
+ /// <reference path="yolo.d.ts" />
@@ -0,0 +1,38 @@
1
+ declare namespace logger {
2
+ /**
3
+ * 设置日志等级
4
+ * @param level 日志等级
5
+ */
6
+ function setLoggerLevel(
7
+ level: "error" | "warn" | "debug" | "info" | "off"
8
+ ): void;
9
+ /**
10
+ * 设置是否输出到文件
11
+ * @param enabled 是否输出到文件
12
+ */
13
+ function setLogToFile(enabled: boolean): void;
14
+ /**
15
+ * 重置日志文件
16
+ */
17
+ function resetLogFile(): void;
18
+ /**
19
+ * 调试日志
20
+ * @param log 日志内容
21
+ */
22
+ function debug(log: string): void;
23
+ /**
24
+ * 信息日志
25
+ * @param log 日志内容
26
+ */
27
+ function info(log: string): void;
28
+ /**
29
+ * 警告日志
30
+ * @param log 日志内容
31
+ */
32
+ function warn(log: string): void;
33
+ /**
34
+ * 错误日志
35
+ * @param log 日志内容
36
+ */
37
+ function error(log: string): void;
38
+ }
@@ -0,0 +1,49 @@
1
+ declare namespace media {
2
+ /**
3
+ * 保存图像到相册
4
+ * @param img 图像ID
5
+ * @returns 是否保存成功
6
+ */
7
+ function saveImageToAlbum(img: string): boolean;
8
+
9
+ /**
10
+ * 保存视频路径到相册
11
+ * @param path 视频文件的路径
12
+ * @returns 是否保存成功
13
+ */
14
+ function saveVideoToAlbumPath(path: string): boolean;
15
+
16
+ /**
17
+ * 清空相册中的图片
18
+ * @returns 是否删除成功
19
+ */
20
+ function deleteAllPhotos(): boolean;
21
+
22
+ /**
23
+ * 清空相册中的视频
24
+ * @returns 是否删除成功
25
+ */
26
+ function deleteAllVideos(): boolean;
27
+
28
+ /**
29
+ * 播放MP3音乐(异步播放)
30
+ * @param path 文件路径
31
+ * @param loop 是否循环播放
32
+ * @returns 是否播放成功
33
+ */
34
+ function playMp3(path: string, loop: boolean): boolean;
35
+
36
+ /**
37
+ * 停止播放mp3音乐
38
+ * @returns 是否停止成功
39
+ */
40
+ function stopMp3(): boolean;
41
+
42
+ /**
43
+ * 同步播放MP3音乐(等待结束)
44
+ * @param path 文件路径
45
+ * @param loop 是否循环播放
46
+ * @returns 是否播放成功
47
+ */
48
+ function playMp3WaitEnd(path: string, loop: boolean): boolean;
49
+ }
@@ -0,0 +1,266 @@
1
+ declare function createNodeSelector(params: {
2
+ /**
3
+ * 1 代表不管visible是true还是false都获取,2 代表只获取 visible=true的节点
4
+ */
5
+ visibleFilter: number;
6
+ /**
7
+ * 1 代表不管label是否有值都获取,2 代表只获取label有值的节点
8
+ */
9
+ labelFilter: number;
10
+ /**
11
+ * 1 代表不过滤 2 bounds 区域属性x,y,w,h都小于0就被过滤
12
+ */
13
+ boundsFilter: number;
14
+ /**
15
+ * 代表要获取节点的层级,越少速度越快,建议 1 - 50
16
+ */
17
+ maxDepth: number;
18
+ /**
19
+ * 最大获取子节点数量,0代表不限制
20
+ */
21
+ maxChildCount: number;
22
+ /**
23
+ * 代表要过滤的属性,用英文逗号分割,可以增加抓取速度,例如 visible,enable
24
+ */
25
+ excludedAttributes: string;
26
+ }): NodeSelector;
27
+
28
+ declare interface NodeBoundsInfo {
29
+ /**
30
+ * x坐标
31
+ */
32
+ x: number;
33
+ /**
34
+ * y坐标
35
+ */
36
+ y: number;
37
+ /**
38
+ * 宽度
39
+ */
40
+ width: number;
41
+ /**
42
+ * 高度
43
+ */
44
+ height: number;
45
+ /**
46
+ * 节点中心x坐标
47
+ */
48
+ centerX: number;
49
+ /**
50
+ * 节点中心y坐标
51
+ */
52
+ centerY: number;
53
+ }
54
+
55
+ declare interface NodeInfo {
56
+ id: number;
57
+ /**
58
+ * 节点标签
59
+ */
60
+ label: string;
61
+ /**
62
+ * 节点类型
63
+ */
64
+ type: string;
65
+ /**
66
+ * 节点值
67
+ */
68
+ value: string;
69
+ /**
70
+ * 节点名称
71
+ */
72
+ name: string;
73
+ /**
74
+ * 节点是否可见
75
+ */
76
+ visible: boolean;
77
+ /**
78
+ * 节点是否启用
79
+ */
80
+ enabled: boolean;
81
+ /**
82
+ * 节点是否可访问
83
+ */
84
+ accessible: boolean;
85
+ /**
86
+ * 节点位置
87
+ */
88
+ bounds: NodeBoundsInfo;
89
+ /**
90
+ * 节点层级
91
+ */
92
+ depth: number;
93
+ /**
94
+ * 节点索引
95
+ */
96
+ index: number;
97
+ /**
98
+ * 父节点id
99
+ */
100
+ parentId: number;
101
+ /**
102
+ * 子节点数量
103
+ */
104
+ childCount: number;
105
+ /**
106
+ * 点击节点中心
107
+ */
108
+ clickCenter(): boolean;
109
+ /**
110
+ * 点击节点随机位置
111
+ */
112
+ clickRandom(): boolean;
113
+ /**
114
+ * 获取父节点
115
+ */
116
+ parent(): NodeInfo;
117
+ /**
118
+ * 获取子节点
119
+ * @param index 子节点索引
120
+ */
121
+ child(index: number): NodeInfo;
122
+ /**
123
+ * 获取所有子节点
124
+ */
125
+ allChildren(): NodeInfo[];
126
+ /**
127
+ * 获取所有兄弟节点
128
+ */
129
+ siblings(): NodeInfo[];
130
+ /**
131
+ * 获取所有前兄弟节点
132
+ */
133
+ previousSiblings(): NodeInfo[];
134
+ /**
135
+ * 获取所有后兄弟节点
136
+ */
137
+ nextSiblings(): NodeInfo[];
138
+ }
139
+
140
+ declare class NodeSelector {
141
+ /**
142
+ * 获取节点信息
143
+ * @param timeout 超时时间,单位毫秒
144
+ * @returns 节点信息数组
145
+ */
146
+ getNodeInfo(timeout: number): NodeInfo[];
147
+ /**
148
+ * 获取一个节点信息
149
+ * @param timeout 超时时间,单位毫秒
150
+ * @returns 节点信息
151
+ */
152
+ getOneNodeInfo(timeout: number): NodeInfo | null;
153
+ /**
154
+ * 加载节点
155
+ */
156
+ loadNode(timeout: number): NodeSelector;
157
+ /**
158
+ * 清除条件
159
+ */
160
+ clearSelector(): NodeSelector;
161
+ /**
162
+ * 获取节点xpath
163
+ * @param path xpath路径
164
+ * @returns 节点选择器
165
+ */
166
+ xpath(path: string): NodeSelector;
167
+ /**
168
+ * 获取节点标签
169
+ * @param label 节点标签
170
+ * @returns 节点选择器
171
+ */
172
+ label(label: string): NodeSelector;
173
+ /**
174
+ * 获取节点标签匹配
175
+ * @param match 匹配字符串
176
+ * @returns 节点选择器
177
+ */
178
+ labelMatch(match: string): NodeSelector;
179
+ /**
180
+ * 获取节点名称
181
+ * @param name 节点名称
182
+ * @returns 节点选择器
183
+ */
184
+ name(name: string): NodeSelector;
185
+ /**
186
+ * 获取节点名称匹配
187
+ * @param match 匹配字符串
188
+ * @returns 节点选择器
189
+ */
190
+ nameMatch(match: string): NodeSelector;
191
+ /**
192
+ * 获取节点类型
193
+ * @param type 节点类型
194
+ * @returns 节点选择器
195
+ */
196
+ type(type: string): NodeSelector;
197
+ /**
198
+ * 获取节点类型匹配
199
+ * @param match 匹配字符串
200
+ * @returns 节点选择器
201
+ */
202
+ typeMatch(match: string): NodeSelector;
203
+ /**
204
+ * 获取节点值
205
+ * @param value 节点值
206
+ * @returns 节点选择器
207
+ */
208
+ value(value: string): NodeSelector;
209
+ /**
210
+ * 获取节点值匹配
211
+ * @param match 匹配字符串
212
+ * @returns 节点选择器
213
+ */
214
+ valueMatch(match: string): NodeSelector;
215
+ /**
216
+ * 获取节点是否启用
217
+ * @param enable 是否启用
218
+ * @returns 节点选择器
219
+ */
220
+ enable(enable: boolean): NodeSelector;
221
+ /**
222
+ * 获取节点是否可访问
223
+ * @param accessible 是否可访问
224
+ * @returns 节点选择器
225
+ */
226
+ accessible(accessible: boolean): NodeSelector;
227
+ /**
228
+ * 获取节点是否可见
229
+ * @param visible 是否可见
230
+ * @returns 节点选择器
231
+ */
232
+ visible(visible: boolean): NodeSelector;
233
+ /**
234
+ * 获取节点索引
235
+ * @param index 节点索引
236
+ * @returns 节点选择器
237
+ */
238
+ index(index: number): NodeSelector;
239
+ /**
240
+ * 获取节点层级
241
+ * @param depth 节点层级
242
+ * @returns 节点选择器
243
+ */
244
+ depth(depth: number): NodeSelector;
245
+ /**
246
+ * 获取节点是否选中
247
+ * @param selected 是否选中
248
+ * @returns 节点选择器
249
+ */
250
+ selected(selected: boolean): NodeSelector;
251
+ /**
252
+ * 获取节点子节点数量
253
+ * @param childCount 子节点数量
254
+ * @returns 节点选择器
255
+ */
256
+ childCount(childCount: string): NodeSelector;
257
+ /**
258
+ * 获取节点位置
259
+ * @param x x坐标
260
+ * @param y y坐标
261
+ * @param width 宽度
262
+ * @param height 高度
263
+ * @returns 节点选择器
264
+ */
265
+ bounds(x: number, y: number, width: number, height: number): NodeSelector;
266
+ }
package/types/ocr.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ declare namespace ocr {
2
+ /**
3
+ * 初始化OCR模型
4
+ * @param useGpu 是否使用GPU,默认false
5
+ * @returns 初始化是否成功
6
+ */
7
+ function loadModel(useGpu: boolean): boolean;
8
+ /**
9
+ * 执行OCR识别
10
+ * @param input 输入源(imageId、URL字符串、文件路径或"screen",nil表示使用当前屏幕)
11
+ * @param x 边界框左上角x坐标
12
+ * @param y 边界框左上角y坐标
13
+ * @param ex 边界框右下角x坐标
14
+ * @param ey 边界框右下角y坐标
15
+ * @returns 识别结果数组
16
+ */
17
+ function recognize(
18
+ input: string | null,
19
+ x: number,
20
+ y: number,
21
+ ex: number,
22
+ ey: number
23
+ ): any[];
24
+ /**
25
+ * 释放OCR模型资源
26
+ */
27
+ function free(): void;
28
+ }