ms-vite-plugin 1.1.1 → 1.1.3
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/dist/build.js +6 -0
- package/dist/cli.js +98 -8
- package/dist/mcp/device-config.d.ts +55 -0
- package/dist/mcp/device-config.js +183 -0
- package/dist/mcp/docs-service.d.ts +65 -0
- package/dist/mcp/docs-service.js +168 -0
- package/dist/mcp/project.d.ts +16 -0
- package/dist/mcp/project.js +74 -0
- package/dist/mcp/tools.d.ts +18 -0
- package/dist/mcp/tools.js +825 -0
- package/dist/mcp/types.d.ts +32 -0
- package/dist/mcp/types.js +11 -0
- package/dist/mcp-server.d.ts +2 -0
- package/dist/mcp-server.js +86 -0
- package/dist/project.d.ts +89 -0
- package/dist/project.js +306 -0
- package/dist/version.d.ts +12 -0
- package/dist/version.js +63 -0
- package/docs/api/action.md +922 -0
- package/docs/api/appleocr.md +229 -0
- package/docs/api/config.md +122 -0
- package/docs/api/cryptoUtils.md +232 -0
- package/docs/api/device.md +374 -0
- package/docs/api/file.md +516 -0
- package/docs/api/global.md +617 -0
- package/docs/api/hid.md +1032 -0
- package/docs/api/hotUpdate.md +166 -0
- package/docs/api/http.md +548 -0
- package/docs/api/image.md +907 -0
- package/docs/api/ime.md +290 -0
- package/docs/api/logger.md +324 -0
- package/docs/api/media.md +248 -0
- package/docs/api/mysql.md +441 -0
- package/docs/api/netCard.md +200 -0
- package/docs/api/node.md +353 -0
- package/docs/api/paddleocr.md +246 -0
- package/docs/api/pip.md +242 -0
- package/docs/api/system.md +572 -0
- package/docs/api/thread.md +269 -0
- package/docs/api/tomatoocr.md +425 -0
- package/docs/api/tts.md +334 -0
- package/docs/api/ui.md +947 -0
- package/docs/api/utils.md +265 -0
- package/docs/api/yolo.md +310 -0
- package/docs/apicn/action.md +919 -0
- package/docs/apicn/appleocr.md +233 -0
- package/docs/apicn/config.md +120 -0
- package/docs/apicn/device.md +385 -0
- package/docs/apicn/file.md +511 -0
- package/docs/apicn/global.md +613 -0
- package/docs/apicn/hid.md +1033 -0
- package/docs/apicn/hotUpdate.md +170 -0
- package/docs/apicn/http.md +672 -0
- package/docs/apicn/image.md +924 -0
- package/docs/apicn/ime.md +290 -0
- package/docs/apicn/logger.md +332 -0
- package/docs/apicn/media.md +252 -0
- package/docs/apicn/mysql.md +445 -0
- package/docs/apicn/netCard.md +200 -0
- package/docs/apicn/node.md +362 -0
- package/docs/apicn/paddleocr.md +255 -0
- package/docs/apicn/pip.md +242 -0
- package/docs/apicn/system.md +575 -0
- package/docs/apicn/thread.md +269 -0
- package/docs/apicn/tts.md +338 -0
- package/docs/apicn/ui.md +933 -0
- package/docs/apicn/utils.md +265 -0
- package/docs/apicn/yolo.md +314 -0
- package/docs/apipython/action.md +901 -0
- package/docs/apipython/appleocr.md +226 -0
- package/docs/apipython/config.md +126 -0
- package/docs/apipython/cryptoUtils.md +246 -0
- package/docs/apipython/device.md +365 -0
- package/docs/apipython/file.md +476 -0
- package/docs/apipython/g.md +154 -0
- package/docs/apipython/hid.md +1059 -0
- package/docs/apipython/hotUpdate.md +154 -0
- package/docs/apipython/image.md +938 -0
- package/docs/apipython/ime.md +306 -0
- package/docs/apipython/logger.md +330 -0
- package/docs/apipython/media.md +221 -0
- package/docs/apipython/mysql.md +432 -0
- package/docs/apipython/netCard.md +219 -0
- package/docs/apipython/node.md +331 -0
- package/docs/apipython/overview.md +66 -0
- package/docs/apipython/paddleocr.md +211 -0
- package/docs/apipython/pip.md +231 -0
- package/docs/apipython/system.md +458 -0
- package/docs/apipython/tomatoocr.md +444 -0
- package/docs/apipython/tts.md +331 -0
- package/docs/apipython/ui.md +949 -0
- package/docs/apipython/utils.md +284 -0
- package/docs/apipython/yolo.md +281 -0
- package/package.json +8 -4
|
@@ -0,0 +1,1059 @@
|
|
|
1
|
+
# HID 模块
|
|
2
|
+
|
|
3
|
+
HID 模块提供全面的输入控制功能,包括点击、滑动、长按滑动、主屏幕导航等操作,通过蓝牙 HID 设备实现。
|
|
4
|
+
|
|
5
|
+
## 常量
|
|
6
|
+
|
|
7
|
+
### hidKey - HID 按键常量
|
|
8
|
+
|
|
9
|
+
预定义的键盘操作按键常量。
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
class hidKey:
|
|
13
|
+
COMMAND: int
|
|
14
|
+
LEFT_CTRL: int
|
|
15
|
+
LEFT_SHIFT: int
|
|
16
|
+
LEFT_ALT: int
|
|
17
|
+
RIGHT_CTRL: int
|
|
18
|
+
RIGHT_SHIFT: int
|
|
19
|
+
RIGHT_ALT: int
|
|
20
|
+
UP_ARROW: int
|
|
21
|
+
DOWN_ARROW: int
|
|
22
|
+
LEFT_ARROW: int
|
|
23
|
+
RIGHT_ARROW: int
|
|
24
|
+
SPACE: int
|
|
25
|
+
BACKSPACE: int
|
|
26
|
+
TAB: int
|
|
27
|
+
RETURN: int
|
|
28
|
+
ESC: int
|
|
29
|
+
INSERT: int
|
|
30
|
+
DELETE: int
|
|
31
|
+
PAGE_UP: int
|
|
32
|
+
PAGE_DOWN: int
|
|
33
|
+
HOME: int
|
|
34
|
+
END: int
|
|
35
|
+
CAPS_LOCK: int
|
|
36
|
+
F1: int
|
|
37
|
+
F2: int
|
|
38
|
+
F3: int
|
|
39
|
+
F4: int
|
|
40
|
+
F5: int
|
|
41
|
+
F6: int
|
|
42
|
+
F7: int
|
|
43
|
+
F8: int
|
|
44
|
+
F9: int
|
|
45
|
+
F10: int
|
|
46
|
+
F11: int
|
|
47
|
+
F12: int
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## 获取和设置设备信息
|
|
51
|
+
|
|
52
|
+
### isBLEConnected - 是否连接了蓝牙HID设备
|
|
53
|
+
|
|
54
|
+
判断是否连接了蓝牙HID设备
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
def isBLEConnected() -> bool:
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**示例:**
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
# 检查是否连接了蓝牙HID设备
|
|
64
|
+
isBLEConnected = hid.isBLEConnected()
|
|
65
|
+
print(isBLEConnected) # 输出: True 或 False
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### isUSBConnected - 是否连接了USB HID设备
|
|
69
|
+
|
|
70
|
+
判断是否连接了USB HID设备
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
def isUSBConnected() -> bool:
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**示例:**
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
# 检查是否连接了USB HID设备
|
|
80
|
+
isUSBConnected = hid.isUSBConnected()
|
|
81
|
+
print(isUSBConnected) # 输出: True 或 False
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### getBLEHIDDeviceName - 获取蓝牙 HID 设备名称
|
|
85
|
+
|
|
86
|
+
获取当前连接的蓝牙 HID 设备名称。
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
def getBLEHIDDeviceName() -> str:
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**返回值:**
|
|
93
|
+
| 类型 | 描述 |
|
|
94
|
+
| ---- | ---- |
|
|
95
|
+
| str | 蓝牙 HID 设备名称 |
|
|
96
|
+
|
|
97
|
+
**示例:**
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from kuaijs import hid
|
|
101
|
+
device_name = hid.getBLEHIDDeviceName()
|
|
102
|
+
print(device_name)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### setBLEHIDDeviceName - 设置蓝牙 HID 设备名称
|
|
106
|
+
|
|
107
|
+
设置当前蓝牙 HID 设备名称。
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
def setBLEHIDDeviceName(name: str) -> bool:
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**参数:**
|
|
114
|
+
| 参数 | 类型 | 必需 | 默认值 | 描述 |
|
|
115
|
+
| ---- | ---- | ---- | ------ | ---- |
|
|
116
|
+
| `name` | str | 是 | - | 要设置的蓝牙 HID 设备名称 |
|
|
117
|
+
|
|
118
|
+
**返回值:**
|
|
119
|
+
| 类型 | 描述 |
|
|
120
|
+
| ---- | ---- |
|
|
121
|
+
| bool | 操作是否成功 |
|
|
122
|
+
|
|
123
|
+
**示例:**
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
from kuaijs import hid
|
|
127
|
+
ok = hid.setBLEHIDDeviceName("KuaiJS-HID")
|
|
128
|
+
print(ok)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### getDeviceMac - 获取设备 MAC 字符串
|
|
132
|
+
|
|
133
|
+
获取设备返回的 MAC 字符串。
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
def getDeviceMac() -> str:
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**返回值:**
|
|
140
|
+
| 类型 | 描述 |
|
|
141
|
+
| ---- | ---- |
|
|
142
|
+
| str | 设备 MAC 字符串 |
|
|
143
|
+
|
|
144
|
+
**示例:**
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
from kuaijs import hid
|
|
148
|
+
mac = hid.getDeviceMac()
|
|
149
|
+
print(mac)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### resetPosition - 复位坐标
|
|
153
|
+
|
|
154
|
+
将鼠标坐标复位到左上角(仅相对鼠标模式需要)。
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
def resetPosition() -> bool:
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**返回值:**
|
|
161
|
+
| 类型 | 描述 |
|
|
162
|
+
| ---- | ---- |
|
|
163
|
+
| bool | 操作是否成功 |
|
|
164
|
+
|
|
165
|
+
**示例:**
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
from kuaijs import hid
|
|
169
|
+
# 复位坐标到左上角
|
|
170
|
+
ok = hid.resetPosition()
|
|
171
|
+
print(ok) # 输出: True 或 False
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## 录屏
|
|
175
|
+
|
|
176
|
+
### openRecordScreen - 打开录屏界面
|
|
177
|
+
|
|
178
|
+
打开录屏界面,用户可以在界面上操作开始、结束录屏。
|
|
179
|
+
|
|
180
|
+
```python
|
|
181
|
+
def openRecordScreen() -> None:
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**示例:**
|
|
185
|
+
|
|
186
|
+
```python
|
|
187
|
+
from kuaijs import hid
|
|
188
|
+
# 打开录屏界面
|
|
189
|
+
hid.openRecordScreen()
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### isRecording - 是否录屏中
|
|
193
|
+
|
|
194
|
+
获取录屏开启状态
|
|
195
|
+
|
|
196
|
+
```python
|
|
197
|
+
def isRecording() -> bool:
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**返回值:**
|
|
201
|
+
| 类型 | 描述 |
|
|
202
|
+
| ---- | ---- |
|
|
203
|
+
| bool | 是否正在录屏 |
|
|
204
|
+
|
|
205
|
+
**示例:**
|
|
206
|
+
|
|
207
|
+
```python
|
|
208
|
+
from kuaijs import hid
|
|
209
|
+
# 检查是否正在录屏
|
|
210
|
+
is_recording = hid.isRecording()
|
|
211
|
+
print(is_recording) # 输出: True 或 False
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## 配置
|
|
215
|
+
|
|
216
|
+
### setJitterValue - 设置抖动值
|
|
217
|
+
|
|
218
|
+
设置动作的抖动值。带有抖动参数的动作将在像素范围`-value`到`value`内随机偏移。
|
|
219
|
+
|
|
220
|
+
```python
|
|
221
|
+
def setJitterValue(value: int) -> None
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
**参数:**
|
|
225
|
+
| 参数 | 类型 | 必需 | 默认值 | 描述 |
|
|
226
|
+
| ---- | ---- | ---- | ------ | ---- |
|
|
227
|
+
| `value` | int | 是 | - | 随机像素偏移的抖动值 |
|
|
228
|
+
|
|
229
|
+
**示例:**
|
|
230
|
+
|
|
231
|
+
```python
|
|
232
|
+
from kuaijs import hid
|
|
233
|
+
# 设置抖动值为5像素
|
|
234
|
+
hid.setJitterValue(5)
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### move - 移动坐标
|
|
238
|
+
|
|
239
|
+
将光标移动到指定坐标。
|
|
240
|
+
|
|
241
|
+
```python
|
|
242
|
+
def move(x: int, y: int) -> bool
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
**参数:**
|
|
246
|
+
| 参数 | 类型 | 必需 | 默认值 | 描述 |
|
|
247
|
+
| ---- | ---- | ---- | ------ | ---- |
|
|
248
|
+
| `x` | int | 是 | - | 目标 X 坐标 |
|
|
249
|
+
| `y` | int | 是 | - | 目标 Y 坐标 |
|
|
250
|
+
|
|
251
|
+
**返回值:**
|
|
252
|
+
| 类型 | 描述 |
|
|
253
|
+
| ---- | ---- |
|
|
254
|
+
| bool | 操作是否成功 |
|
|
255
|
+
|
|
256
|
+
**示例:**
|
|
257
|
+
|
|
258
|
+
```python
|
|
259
|
+
from kuaijs import hid
|
|
260
|
+
# 移动到 (100, 200)
|
|
261
|
+
hid.move(100, 200)
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## 基础触摸操作
|
|
265
|
+
|
|
266
|
+
### click - 点击操作
|
|
267
|
+
|
|
268
|
+
在指定坐标执行点击操作。
|
|
269
|
+
|
|
270
|
+
```python
|
|
271
|
+
def click(
|
|
272
|
+
x: int,
|
|
273
|
+
y: int,
|
|
274
|
+
duration: int = 10,
|
|
275
|
+
jitter: bool = False
|
|
276
|
+
) -> bool
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
**参数:**
|
|
280
|
+
| 参数 | 类型 | 必需 | 默认值 | 描述 |
|
|
281
|
+
| ---- | ---- | ---- | ------ | ---- |
|
|
282
|
+
| `x` | int | 是 | - | 点击的 X 坐标 |
|
|
283
|
+
| `y` | int | 是 | - | 点击的 Y 坐标 |
|
|
284
|
+
| `duration` | int | 否 | 10 | 点击持续时间(毫秒) |
|
|
285
|
+
| `jitter` | bool | 否 | False | 启用随机抖动偏移 |
|
|
286
|
+
|
|
287
|
+
**返回值:**
|
|
288
|
+
| 类型 | 描述 |
|
|
289
|
+
| ---- | ---- |
|
|
290
|
+
| bool | 操作是否成功 |
|
|
291
|
+
|
|
292
|
+
**示例:**
|
|
293
|
+
|
|
294
|
+
```python
|
|
295
|
+
from kuaijs import hid
|
|
296
|
+
# 简单点击
|
|
297
|
+
hid.click(100, 200)
|
|
298
|
+
|
|
299
|
+
# 带持续时间和抖动的点击
|
|
300
|
+
hid.click(100, 200, 150, True)
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### clickRandom - 随机点击
|
|
304
|
+
|
|
305
|
+
在指定矩形区域内执行随机点击。
|
|
306
|
+
|
|
307
|
+
```python
|
|
308
|
+
def clickRandom(
|
|
309
|
+
x1: int,
|
|
310
|
+
y1: int,
|
|
311
|
+
x2: int,
|
|
312
|
+
y2: int,
|
|
313
|
+
duration: int = 20
|
|
314
|
+
) -> bool
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
**参数:**
|
|
318
|
+
| 参数 | 类型 | 必需 | 默认值 | 描述 |
|
|
319
|
+
| ---- | ---- | ---- | ------ | ---- |
|
|
320
|
+
| `x1` | int | 是 | - | 左上角 X 坐标 |
|
|
321
|
+
| `y1` | int | 是 | - | 左上角 Y 坐标 |
|
|
322
|
+
| `x2` | int | 是 | - | 右下角 X 坐标 |
|
|
323
|
+
| `y2` | int | 是 | - | 右下角 Y 坐标 |
|
|
324
|
+
| `duration` | int | 否 | 20 | 点击持续时间(毫秒) |
|
|
325
|
+
|
|
326
|
+
**返回值:**
|
|
327
|
+
| 类型 | 描述 |
|
|
328
|
+
| ---- | ---- |
|
|
329
|
+
| bool | 操作是否成功 |
|
|
330
|
+
|
|
331
|
+
**示例:**
|
|
332
|
+
|
|
333
|
+
```python
|
|
334
|
+
from kuaijs import hid
|
|
335
|
+
# 在区域内随机点击
|
|
336
|
+
hid.clickRandom(100, 100, 200, 200, 20)
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### doubleClick - 双击
|
|
340
|
+
|
|
341
|
+
在指定坐标执行双击操作。
|
|
342
|
+
|
|
343
|
+
```python
|
|
344
|
+
def doubleClick(
|
|
345
|
+
x: int,
|
|
346
|
+
y: int,
|
|
347
|
+
duration: int = 20,
|
|
348
|
+
interval: int = 20,
|
|
349
|
+
jitter: bool = False
|
|
350
|
+
) -> bool
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
**参数:**
|
|
354
|
+
| 参数 | 类型 | 必需 | 默认值 | 描述 |
|
|
355
|
+
| ---- | ---- | ---- | ------ | ---- |
|
|
356
|
+
| `x` | int | 是 | - | X 坐标 |
|
|
357
|
+
| `y` | int | 是 | - | Y 坐标 |
|
|
358
|
+
| `duration` | int | 否 | 20 | 点击持续时间(毫秒) |
|
|
359
|
+
| `interval` | int | 否 | 20 | 两次点击间隔时间(毫秒) |
|
|
360
|
+
| `jitter` | bool | 否 | False | 启用随机抖动偏移 |
|
|
361
|
+
|
|
362
|
+
**返回值:**
|
|
363
|
+
| 类型 | 描述 |
|
|
364
|
+
| ---- | ---- |
|
|
365
|
+
| bool | 操作是否成功 |
|
|
366
|
+
|
|
367
|
+
**示例:**
|
|
368
|
+
|
|
369
|
+
```python
|
|
370
|
+
from kuaijs import hid
|
|
371
|
+
# 带抖动的双击
|
|
372
|
+
hid.doubleClick(100, 100, 20, 20, True)
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### doubleClickRandom - 随机双击
|
|
376
|
+
|
|
377
|
+
在指定矩形区域内执行随机双击。
|
|
378
|
+
|
|
379
|
+
```python
|
|
380
|
+
def doubleClickRandom(
|
|
381
|
+
x1: int,
|
|
382
|
+
y1: int,
|
|
383
|
+
x2: int,
|
|
384
|
+
y2: int,
|
|
385
|
+
duration: int = 20,
|
|
386
|
+
interval: int = 20
|
|
387
|
+
) -> bool
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
**参数:**
|
|
391
|
+
| 参数 | 类型 | 必需 | 默认值 | 描述 |
|
|
392
|
+
| ---- | ---- | ---- | ------ | ---- |
|
|
393
|
+
| `x1` | int | 是 | - | 左上角 X 坐标 |
|
|
394
|
+
| `y1` | int | 是 | - | 左上角 Y 坐标 |
|
|
395
|
+
| `x2` | int | 是 | - | 右下角 X 坐标 |
|
|
396
|
+
| `y2` | int | 是 | - | 右下角 Y 坐标 |
|
|
397
|
+
| `duration` | int | 否 | 20 | 点击持续时间(毫秒) |
|
|
398
|
+
| `interval` | int | 否 | 20 | 两次点击间隔时间(毫秒) |
|
|
399
|
+
|
|
400
|
+
**返回值:**
|
|
401
|
+
| 类型 | 描述 |
|
|
402
|
+
| ---- | ---- |
|
|
403
|
+
| bool | 操作是否成功 |
|
|
404
|
+
|
|
405
|
+
**示例:**
|
|
406
|
+
|
|
407
|
+
```python
|
|
408
|
+
from kuaijs import hid
|
|
409
|
+
# 在区域内随机双击
|
|
410
|
+
hid.doubleClickRandom(100, 100, 200, 200, 20, 20)
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
## 滑动操作
|
|
414
|
+
|
|
415
|
+
### swipe - 线性滑动
|
|
416
|
+
|
|
417
|
+
执行从起始坐标到结束坐标的线性滑动。
|
|
418
|
+
|
|
419
|
+
```python
|
|
420
|
+
def swipe(
|
|
421
|
+
x: int,
|
|
422
|
+
y: int,
|
|
423
|
+
ex: int,
|
|
424
|
+
ey: int,
|
|
425
|
+
jitter: bool = False,
|
|
426
|
+
steps: int = 6
|
|
427
|
+
) -> bool
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
**参数:**
|
|
431
|
+
| 参数 | 类型 | 必需 | 默认值 | 描述 |
|
|
432
|
+
| ---- | ---- | ---- | ------ | ---- |
|
|
433
|
+
| `x` | int | 是 | - | 起始 X 坐标 |
|
|
434
|
+
| `y` | int | 是 | - | 起始 Y 坐标 |
|
|
435
|
+
| `ex` | int | 是 | - | 结束 X 坐标 |
|
|
436
|
+
| `ey` | int | 是 | - | 结束 Y 坐标 |
|
|
437
|
+
| `jitter` | bool | 否 | False | 启用随机抖动偏移 |
|
|
438
|
+
| `steps` | int | 否 | 6 | 滑动步数 |
|
|
439
|
+
|
|
440
|
+
**返回值:**
|
|
441
|
+
| 类型 | 描述 |
|
|
442
|
+
| ---- | ---- |
|
|
443
|
+
| bool | 操作是否成功 |
|
|
444
|
+
|
|
445
|
+
**示例:**
|
|
446
|
+
|
|
447
|
+
```python
|
|
448
|
+
from kuaijs import hid
|
|
449
|
+
# 简单滑动
|
|
450
|
+
hid.swipe(100, 100, 200, 200)
|
|
451
|
+
|
|
452
|
+
# 带抖动和自定义步数的滑动
|
|
453
|
+
hid.swipe(100, 100, 200, 200, True, 10)
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
### pressAndSwipe - 长按并滑动
|
|
457
|
+
|
|
458
|
+
长按起始坐标,然后滑动到目标坐标。
|
|
459
|
+
|
|
460
|
+
```python
|
|
461
|
+
def pressAndSwipe(
|
|
462
|
+
x: int,
|
|
463
|
+
y: int,
|
|
464
|
+
ex: int,
|
|
465
|
+
ey: int,
|
|
466
|
+
duration: int = 500,
|
|
467
|
+
jitter: bool = False,
|
|
468
|
+
steps: int = 6
|
|
469
|
+
) -> bool
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
**参数:**
|
|
473
|
+
| 参数 | 类型 | 必需 | 默认值 | 描述 |
|
|
474
|
+
| ---- | ---- | ---- | ------ | ---- |
|
|
475
|
+
| `x` | int | 是 | - | 起始 X 坐标 |
|
|
476
|
+
| `y` | int | 是 | - | 起始 Y 坐标 |
|
|
477
|
+
| `ex` | int | 是 | - | 结束 X 坐标 |
|
|
478
|
+
| `ey` | int | 是 | - | 结束 Y 坐标 |
|
|
479
|
+
| `duration` | int | 否 | 500 | 长按持续时间(毫秒) |
|
|
480
|
+
| `jitter` | bool | 否 | False | 启用随机抖动偏移 |
|
|
481
|
+
| `steps` | int | 否 | 6 | 滑动步数 |
|
|
482
|
+
|
|
483
|
+
**返回值:**
|
|
484
|
+
| 类型 | 描述 |
|
|
485
|
+
| ---- | ---- |
|
|
486
|
+
| bool | 操作是否成功 |
|
|
487
|
+
|
|
488
|
+
**示例:**
|
|
489
|
+
|
|
490
|
+
```python
|
|
491
|
+
from kuaijs import hid
|
|
492
|
+
# 长按 1 秒后滑动
|
|
493
|
+
hid.pressAndSwipe(100, 100, 200, 200, 1000)
|
|
494
|
+
|
|
495
|
+
# 长按 1 秒后带抖动和自定义步数的滑动
|
|
496
|
+
hid.pressAndSwipe(100, 100, 200, 200, 1000, True, 10)
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
### swipeCurve - 曲线滑动
|
|
500
|
+
|
|
501
|
+
执行 3 点曲线滑动(先快后慢),通过起始点、中间点和结束点。
|
|
502
|
+
|
|
503
|
+
```python
|
|
504
|
+
def swipeCurve(
|
|
505
|
+
startX: int,
|
|
506
|
+
startY: int,
|
|
507
|
+
midX: int,
|
|
508
|
+
midY: int,
|
|
509
|
+
endX: int,
|
|
510
|
+
endY: int
|
|
511
|
+
) -> bool
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
**参数:**
|
|
515
|
+
| 参数 | 类型 | 必需 | 默认值 | 描述 |
|
|
516
|
+
| ---- | ---- | ---- | ------ | ---- |
|
|
517
|
+
| `startX` | int | 是 | - | 起始 X 坐标 |
|
|
518
|
+
| `startY` | int | 是 | - | 起始 Y 坐标 |
|
|
519
|
+
| `midX` | int | 是 | - | 中间点 X 坐标 |
|
|
520
|
+
| `midY` | int | 是 | - | 中间点 Y 坐标 |
|
|
521
|
+
| `endX` | int | 是 | - | 结束 X 坐标 |
|
|
522
|
+
| `endY` | int | 是 | - | 结束 Y 坐标 |
|
|
523
|
+
|
|
524
|
+
**返回值:**
|
|
525
|
+
| 类型 | 描述 |
|
|
526
|
+
| ---- | ---- |
|
|
527
|
+
| bool | 操作是否成功 |
|
|
528
|
+
|
|
529
|
+
**示例:**
|
|
530
|
+
|
|
531
|
+
```python
|
|
532
|
+
from kuaijs import hid
|
|
533
|
+
# 通过三个点的曲线滑动
|
|
534
|
+
hid.swipeCurve(100, 100, 150, 50, 200, 100)
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
## 系统导航
|
|
538
|
+
|
|
539
|
+
### homeScreen - 返回主屏幕
|
|
540
|
+
|
|
541
|
+
返回到设备主屏幕。
|
|
542
|
+
|
|
543
|
+
```python
|
|
544
|
+
def homeScreen() -> bool
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
**返回值:**
|
|
548
|
+
| 类型 | 描述 |
|
|
549
|
+
| ---- | ---- |
|
|
550
|
+
| bool | 操作是否成功 |
|
|
551
|
+
|
|
552
|
+
**示例:**
|
|
553
|
+
|
|
554
|
+
```python
|
|
555
|
+
from kuaijs import hid
|
|
556
|
+
# 回到主屏幕
|
|
557
|
+
hid.homeScreen()
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
## 文本输入
|
|
561
|
+
|
|
562
|
+
### input - 文本输入
|
|
563
|
+
|
|
564
|
+
输入文本。
|
|
565
|
+
|
|
566
|
+
```python
|
|
567
|
+
def input(text: str) -> bool
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
**参数:**
|
|
571
|
+
| 参数 | 类型 | 必需 | 默认值 | 描述 |
|
|
572
|
+
| ---- | ---- | ---- | ------ | ---- |
|
|
573
|
+
| `text` | str | 是 | - | 要输入的文本 |
|
|
574
|
+
|
|
575
|
+
**返回值:**
|
|
576
|
+
| 类型 | 描述 |
|
|
577
|
+
| ---- | ---- |
|
|
578
|
+
| bool | 操作是否成功 |
|
|
579
|
+
|
|
580
|
+
**示例:**
|
|
581
|
+
|
|
582
|
+
```python
|
|
583
|
+
from kuaijs import hid
|
|
584
|
+
# 输入文本
|
|
585
|
+
hid.input("Hello World")
|
|
586
|
+
|
|
587
|
+
# 输入中文
|
|
588
|
+
hid.input("测试")
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
### inputSimple - 基础文本输入
|
|
592
|
+
|
|
593
|
+
输入基础文本(不支持中文),等价于键盘逐字输出。
|
|
594
|
+
|
|
595
|
+
```python
|
|
596
|
+
def inputSimple(text: str) -> bool
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
**参数:**
|
|
600
|
+
| 参数 | 类型 | 必需 | 默认值 | 描述 |
|
|
601
|
+
| ---- | ---- | ---- | ------ | ---- |
|
|
602
|
+
| `text` | str | 是 | - | 要输入的基础文本(建议 ASCII) |
|
|
603
|
+
|
|
604
|
+
**返回值:**
|
|
605
|
+
| 类型 | 描述 |
|
|
606
|
+
| ---- | ---- |
|
|
607
|
+
| bool | 操作是否成功 |
|
|
608
|
+
|
|
609
|
+
**示例:**
|
|
610
|
+
|
|
611
|
+
```python
|
|
612
|
+
from kuaijs import hid
|
|
613
|
+
# 输入英文与数字
|
|
614
|
+
hid.inputSimple("hello_123")
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
## 基础按键操作
|
|
618
|
+
|
|
619
|
+
### space - 空格键
|
|
620
|
+
|
|
621
|
+
发送空格键按下。
|
|
622
|
+
|
|
623
|
+
```python
|
|
624
|
+
def space() -> bool
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
**返回值:**
|
|
628
|
+
| 类型 | 描述 |
|
|
629
|
+
| ---- | ---- |
|
|
630
|
+
| bool | 操作是否成功 |
|
|
631
|
+
|
|
632
|
+
**示例:**
|
|
633
|
+
|
|
634
|
+
```python
|
|
635
|
+
from kuaijs import hid
|
|
636
|
+
hid.space()
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
### backspace - 退格键
|
|
640
|
+
|
|
641
|
+
发送退格键按下。
|
|
642
|
+
|
|
643
|
+
```python
|
|
644
|
+
def backspace() -> bool
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
**返回值:**
|
|
648
|
+
| 类型 | 描述 |
|
|
649
|
+
| ---- | ---- |
|
|
650
|
+
| bool | 操作是否成功 |
|
|
651
|
+
|
|
652
|
+
**示例:**
|
|
653
|
+
|
|
654
|
+
```python
|
|
655
|
+
from kuaijs import hid
|
|
656
|
+
hid.backspace()
|
|
657
|
+
```
|
|
658
|
+
|
|
659
|
+
### enter - 回车键
|
|
660
|
+
|
|
661
|
+
发送回车/换行键按下。
|
|
662
|
+
|
|
663
|
+
```python
|
|
664
|
+
def enter() -> bool
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
**返回值:**
|
|
668
|
+
| 类型 | 描述 |
|
|
669
|
+
| ---- | ---- |
|
|
670
|
+
| bool | 操作是否成功 |
|
|
671
|
+
|
|
672
|
+
**示例:**
|
|
673
|
+
|
|
674
|
+
```python
|
|
675
|
+
from kuaijs import hid
|
|
676
|
+
hid.enter()
|
|
677
|
+
```
|
|
678
|
+
|
|
679
|
+
### pressButton - 按下系统按钮
|
|
680
|
+
|
|
681
|
+
```python
|
|
682
|
+
def pressButton(button: Literal["home", "volumeup", "volumedown", "eject"]) -> bool
|
|
683
|
+
```
|
|
684
|
+
|
|
685
|
+
**参数说明:**
|
|
686
|
+
|
|
687
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
688
|
+
| -------- | ------- | -------- | ------ | ------------------------------------------------------------------------------------------------------------------------ |
|
|
689
|
+
| `button` | Literal | 是 | - | 按钮类型: <br>-`"home"` Home 键 <br>- `"volumeup"` 音量上键 <br>- `"volumedown"` 音量下键 <br>- `"eject"` 显示/隐藏键盘 |
|
|
690
|
+
|
|
691
|
+
**返回值:**
|
|
692
|
+
|
|
693
|
+
| 类型 | 描述 |
|
|
694
|
+
| ------ | ---------------- |
|
|
695
|
+
| `bool` | 按下按钮是否成功 |
|
|
696
|
+
|
|
697
|
+
**示例:**
|
|
698
|
+
|
|
699
|
+
```python
|
|
700
|
+
from kuaijs import hid
|
|
701
|
+
|
|
702
|
+
# 按下 Home 键
|
|
703
|
+
hid.pressButton("home")
|
|
704
|
+
|
|
705
|
+
# 调高音量
|
|
706
|
+
hid.pressButton("volumeup")
|
|
707
|
+
|
|
708
|
+
# 调低音量
|
|
709
|
+
hid.pressButton("volumedown")
|
|
710
|
+
|
|
711
|
+
# 连续调节音量
|
|
712
|
+
for i in range(5):
|
|
713
|
+
hid.pressButton("volumeup")
|
|
714
|
+
```
|
|
715
|
+
|
|
716
|
+
## 组合键
|
|
717
|
+
|
|
718
|
+
### sendKey - 发送组合键
|
|
719
|
+
|
|
720
|
+
发送组合键。
|
|
721
|
+
|
|
722
|
+
```python
|
|
723
|
+
def sendKey(key: List[Union[int, str]]) -> bool
|
|
724
|
+
```
|
|
725
|
+
|
|
726
|
+
**参数:**
|
|
727
|
+
| 参数 | 类型 | 必需 | 默认值 | 描述 |
|
|
728
|
+
| ---- | ---- | ---- | ------ | ---- |
|
|
729
|
+
| `key` | List[int \| str] | 是 | - | 要发送的按键数组 |
|
|
730
|
+
|
|
731
|
+
**返回值:**
|
|
732
|
+
| 类型 | 描述 |
|
|
733
|
+
| ---- | ---- |
|
|
734
|
+
| bool | 操作是否成功 |
|
|
735
|
+
|
|
736
|
+
**示例:**
|
|
737
|
+
|
|
738
|
+
```python
|
|
739
|
+
from kuaijs import hid
|
|
740
|
+
# 发送Cmd+C
|
|
741
|
+
hid.sendKey([hid.hidKey.COMMAND, "c"])
|
|
742
|
+
|
|
743
|
+
# 发送Ctrl+Alt+Delete
|
|
744
|
+
hid.sendKey([hid.hidKey.LEFT_CTRL, hid.hidKey.LEFT_ALT, hid.hidKey.DELETE])
|
|
745
|
+
```
|
|
746
|
+
|
|
747
|
+
### copyText - 复制文本
|
|
748
|
+
|
|
749
|
+
发送 Command+C 复制文本。
|
|
750
|
+
|
|
751
|
+
```python
|
|
752
|
+
def copyText() -> bool
|
|
753
|
+
```
|
|
754
|
+
|
|
755
|
+
**返回值:**
|
|
756
|
+
| 类型 | 描述 |
|
|
757
|
+
| ---- | ---- |
|
|
758
|
+
| bool | 操作是否成功 |
|
|
759
|
+
|
|
760
|
+
**示例:**
|
|
761
|
+
|
|
762
|
+
```python
|
|
763
|
+
from kuaijs import hid
|
|
764
|
+
hid.copyText()
|
|
765
|
+
```
|
|
766
|
+
|
|
767
|
+
### pasteText - 粘贴文本
|
|
768
|
+
|
|
769
|
+
发送 Command+V 粘贴文本。
|
|
770
|
+
|
|
771
|
+
```python
|
|
772
|
+
def pasteText() -> bool
|
|
773
|
+
```
|
|
774
|
+
|
|
775
|
+
**返回值:**
|
|
776
|
+
| 类型 | 描述 |
|
|
777
|
+
| ---- | ---- |
|
|
778
|
+
| bool | 操作是否成功 |
|
|
779
|
+
|
|
780
|
+
**示例:**
|
|
781
|
+
|
|
782
|
+
```python
|
|
783
|
+
from kuaijs import hid
|
|
784
|
+
hid.pasteText()
|
|
785
|
+
```
|
|
786
|
+
|
|
787
|
+
## 导航快捷键
|
|
788
|
+
|
|
789
|
+
### back - 返回
|
|
790
|
+
|
|
791
|
+
发送 Tab+B 进行返回导航。
|
|
792
|
+
|
|
793
|
+
```python
|
|
794
|
+
def back() -> bool
|
|
795
|
+
```
|
|
796
|
+
|
|
797
|
+
**返回值:**
|
|
798
|
+
| 类型 | 描述 |
|
|
799
|
+
| ---- | ---- |
|
|
800
|
+
| bool | 操作是否成功 |
|
|
801
|
+
|
|
802
|
+
**示例:**
|
|
803
|
+
|
|
804
|
+
```python
|
|
805
|
+
from kuaijs import hid
|
|
806
|
+
hid.back()
|
|
807
|
+
```
|
|
808
|
+
|
|
809
|
+
### recent - 最近应用
|
|
810
|
+
|
|
811
|
+
显示 APP 切换器
|
|
812
|
+
|
|
813
|
+
```python
|
|
814
|
+
def recent() -> bool
|
|
815
|
+
```
|
|
816
|
+
|
|
817
|
+
**返回值:**
|
|
818
|
+
| 类型 | 描述 |
|
|
819
|
+
| ---- | ---- |
|
|
820
|
+
| bool | 操作是否成功 |
|
|
821
|
+
|
|
822
|
+
**示例:**
|
|
823
|
+
|
|
824
|
+
```python
|
|
825
|
+
from kuaijs import hid
|
|
826
|
+
hid.recent()
|
|
827
|
+
```
|
|
828
|
+
|
|
829
|
+
### lock - 锁屏
|
|
830
|
+
|
|
831
|
+
发送锁定屏幕指令。
|
|
832
|
+
|
|
833
|
+
```python
|
|
834
|
+
def lock() -> bool
|
|
835
|
+
```
|
|
836
|
+
|
|
837
|
+
**返回值:**
|
|
838
|
+
| 类型 | 描述 |
|
|
839
|
+
| ---- | ---- |
|
|
840
|
+
| bool | 操作是否成功 |
|
|
841
|
+
|
|
842
|
+
**示例:**
|
|
843
|
+
|
|
844
|
+
```python
|
|
845
|
+
from kuaijs import hid
|
|
846
|
+
hid.lock()
|
|
847
|
+
```
|
|
848
|
+
|
|
849
|
+
### unlock - 解锁
|
|
850
|
+
|
|
851
|
+
发送两次 Home 键解锁屏幕。
|
|
852
|
+
|
|
853
|
+
```python
|
|
854
|
+
def unlock() -> bool
|
|
855
|
+
```
|
|
856
|
+
|
|
857
|
+
**返回值:**
|
|
858
|
+
| 类型 | 描述 |
|
|
859
|
+
| ---- | ---- |
|
|
860
|
+
| bool | 操作是否成功 |
|
|
861
|
+
|
|
862
|
+
**示例:**
|
|
863
|
+
|
|
864
|
+
```python
|
|
865
|
+
from kuaijs import hid
|
|
866
|
+
hid.unlock()
|
|
867
|
+
```
|
|
868
|
+
|
|
869
|
+
## 应用控制
|
|
870
|
+
|
|
871
|
+
### openURL - 打开 URL
|
|
872
|
+
|
|
873
|
+
在默认浏览器或相应应用中打开 URL。
|
|
874
|
+
|
|
875
|
+
```python
|
|
876
|
+
def openURL(url: str) -> bool
|
|
877
|
+
```
|
|
878
|
+
|
|
879
|
+
**参数:**
|
|
880
|
+
| 参数 | 类型 | 必需 | 默认值 | 描述 |
|
|
881
|
+
| ---- | ---- | ---- | ------ | ---- |
|
|
882
|
+
| `url` | str | 是 | - | 要打开的 URL |
|
|
883
|
+
|
|
884
|
+
**返回值:**
|
|
885
|
+
| 类型 | 描述 |
|
|
886
|
+
| ---- | ---- |
|
|
887
|
+
| bool | 操作是否成功 |
|
|
888
|
+
|
|
889
|
+
**示例:**
|
|
890
|
+
|
|
891
|
+
```python
|
|
892
|
+
from kuaijs import hid
|
|
893
|
+
# 打开网站
|
|
894
|
+
hid.openURL("https://www.example.com")
|
|
895
|
+
|
|
896
|
+
# 使用自定义scheme打开应用
|
|
897
|
+
hid.openURL("myapp://action")
|
|
898
|
+
```
|
|
899
|
+
|
|
900
|
+
### openApp - 打开应用
|
|
901
|
+
|
|
902
|
+
按名称打开应用程序。
|
|
903
|
+
|
|
904
|
+
```python
|
|
905
|
+
def openApp(name: str) -> bool
|
|
906
|
+
```
|
|
907
|
+
|
|
908
|
+
**参数:**
|
|
909
|
+
| 参数 | 类型 | 必需 | 默认值 | 描述 |
|
|
910
|
+
| ---- | ---- | ---- | ------ | ---- |
|
|
911
|
+
| `name` | str | 是 | - | 应用程序名称 或者 包名 |
|
|
912
|
+
|
|
913
|
+
**返回值:**
|
|
914
|
+
| 类型 | 描述 |
|
|
915
|
+
| ---- | ---- |
|
|
916
|
+
| bool | 操作是否成功 |
|
|
917
|
+
|
|
918
|
+
**示例:**
|
|
919
|
+
|
|
920
|
+
```python
|
|
921
|
+
from kuaijs import hid
|
|
922
|
+
# 打开Safari
|
|
923
|
+
hid.openApp("Safari")
|
|
924
|
+
|
|
925
|
+
# 打开设置
|
|
926
|
+
hid.openApp("Settings")
|
|
927
|
+
|
|
928
|
+
# 按 bundleId 打开应用
|
|
929
|
+
hid.openApp("com.example.myapp")
|
|
930
|
+
```
|
|
931
|
+
|
|
932
|
+
### closeApp - 关闭应用
|
|
933
|
+
|
|
934
|
+
按名称关闭应用程序。
|
|
935
|
+
|
|
936
|
+
```python
|
|
937
|
+
def closeApp(name: str) -> bool
|
|
938
|
+
```
|
|
939
|
+
|
|
940
|
+
**参数:**
|
|
941
|
+
| 参数 | 类型 | 必需 | 默认值 | 描述 |
|
|
942
|
+
| ---- | ---- | ---- | ------ | ---- |
|
|
943
|
+
| `name` | str | 是 | - | 应用程序名称 或者 包名 |
|
|
944
|
+
|
|
945
|
+
**返回值:**
|
|
946
|
+
| 类型 | 描述 |
|
|
947
|
+
| ---- | ---- |
|
|
948
|
+
| bool | 操作是否成功 |
|
|
949
|
+
|
|
950
|
+
**示例:**
|
|
951
|
+
|
|
952
|
+
```python
|
|
953
|
+
from kuaijs import hid
|
|
954
|
+
# 关闭Safari
|
|
955
|
+
hid.closeApp("Safari")
|
|
956
|
+
|
|
957
|
+
# 关闭设置
|
|
958
|
+
hid.closeApp("Settings")
|
|
959
|
+
|
|
960
|
+
# 按 bundleId 关闭应用
|
|
961
|
+
hid.closeApp("com.example.myapp")
|
|
962
|
+
```
|
|
963
|
+
|
|
964
|
+
### takeMeToFront - 置于前台
|
|
965
|
+
|
|
966
|
+
将当前应用置于前台。
|
|
967
|
+
|
|
968
|
+
```python
|
|
969
|
+
def takeMeToFront() -> bool
|
|
970
|
+
```
|
|
971
|
+
|
|
972
|
+
**返回值:**
|
|
973
|
+
| 类型 | 描述 |
|
|
974
|
+
| ---- | ---- |
|
|
975
|
+
| bool | 操作是否成功 |
|
|
976
|
+
|
|
977
|
+
**示例:**
|
|
978
|
+
|
|
979
|
+
```python
|
|
980
|
+
from kuaijs import hid
|
|
981
|
+
hid.takeMeToFront()
|
|
982
|
+
```
|
|
983
|
+
|
|
984
|
+
### currentAppInfo - 获取当前应用信息
|
|
985
|
+
|
|
986
|
+
获取当前打开应用的信息(仅 iOS 18.2+)。
|
|
987
|
+
|
|
988
|
+
```python
|
|
989
|
+
def currentAppInfo() -> Optional[dict]
|
|
990
|
+
```
|
|
991
|
+
|
|
992
|
+
**返回值:**
|
|
993
|
+
| 类型 | 描述 |
|
|
994
|
+
| ---- | ---- |
|
|
995
|
+
| dict \| None | 当前应用信息或 None(如果不可用) |
|
|
996
|
+
|
|
997
|
+
**返回字典属性:**
|
|
998
|
+
| 属性 | 类型 | 描述 |
|
|
999
|
+
| ---- | ---- | ---- |
|
|
1000
|
+
| `name` | str | 应用程序名称 |
|
|
1001
|
+
| `bundleId` | str | 应用程序包 ID |
|
|
1002
|
+
|
|
1003
|
+
**示例:**
|
|
1004
|
+
|
|
1005
|
+
```python
|
|
1006
|
+
from kuaijs import hid
|
|
1007
|
+
app_info = hid.currentAppInfo()
|
|
1008
|
+
if app_info:
|
|
1009
|
+
print(f"当前应用: {app_info.name} ({app_info.bundleId})")
|
|
1010
|
+
```
|
|
1011
|
+
|
|
1012
|
+
## 剪贴板操作
|
|
1013
|
+
|
|
1014
|
+
### setClipboard - 设置剪贴板内容
|
|
1015
|
+
|
|
1016
|
+
设置剪贴板内容。
|
|
1017
|
+
|
|
1018
|
+
```python
|
|
1019
|
+
def setClipboard(text: str) -> bool
|
|
1020
|
+
```
|
|
1021
|
+
|
|
1022
|
+
**参数:**
|
|
1023
|
+
| 参数 | 类型 | 必需 | 默认值 | 描述 |
|
|
1024
|
+
| ---- | ---- | ---- | ------ | ---- |
|
|
1025
|
+
| `text` | str | 是 | - | 要设置到剪贴板的文本 |
|
|
1026
|
+
|
|
1027
|
+
**返回值:**
|
|
1028
|
+
| 类型 | 描述 |
|
|
1029
|
+
| ---- | ---- |
|
|
1030
|
+
| bool | 操作是否成功 |
|
|
1031
|
+
|
|
1032
|
+
**示例:**
|
|
1033
|
+
|
|
1034
|
+
```python
|
|
1035
|
+
from kuaijs import hid
|
|
1036
|
+
hid.setClipboard("你好,世界!")
|
|
1037
|
+
```
|
|
1038
|
+
|
|
1039
|
+
### getClipboard - 获取剪贴板内容
|
|
1040
|
+
|
|
1041
|
+
获取当前剪贴板内容。
|
|
1042
|
+
|
|
1043
|
+
```python
|
|
1044
|
+
def getClipboard() -> str
|
|
1045
|
+
```
|
|
1046
|
+
|
|
1047
|
+
**返回值:**
|
|
1048
|
+
| 类型 | 描述 |
|
|
1049
|
+
| ---- | ---- |
|
|
1050
|
+
| str | 剪贴板内容或 `""`(如果不可用) |
|
|
1051
|
+
|
|
1052
|
+
**示例:**
|
|
1053
|
+
|
|
1054
|
+
```python
|
|
1055
|
+
from kuaijs import hid
|
|
1056
|
+
clipboard_text = hid.getClipboard()
|
|
1057
|
+
if clipboard_text:
|
|
1058
|
+
print("剪贴板内容:", clipboard_text)
|
|
1059
|
+
```
|