MaaFw 2.1.0__py3-none-manylinux2014_x86_64.whl → 5.4.0b1__py3-none-manylinux2014_x86_64.whl
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.
- maa/__init__.py +7 -5
- maa/agent/__init__.py +12 -0
- maa/agent/agent_server.py +350 -0
- maa/agent_client.py +291 -0
- maa/bin/libMaaAdbControlUnit.so +0 -0
- maa/bin/libMaaAgentClient.so +0 -0
- maa/bin/libMaaAgentServer.so +0 -0
- maa/bin/libMaaCustomControlUnit.so +0 -0
- maa/bin/libMaaFramework.so +0 -0
- maa/bin/libMaaToolkit.so +0 -0
- maa/bin/libMaaUtils.so +0 -0
- maa/bin/libc++.so.1 +0 -0
- maa/bin/libc++abi.so.1 +0 -0
- maa/bin/libfastdeploy_ppocr.so +0 -0
- maa/bin/{libopencv_world4.so.408 → libonnxruntime.so.1} +0 -0
- maa/bin/{libonnxruntime.so.1.18.0 → libopencv_world4.so.411} +0 -0
- maa/bin/libunwind.so.1 +0 -0
- maa/bin/plugins/libMaaPluginDemo.so +0 -0
- maa/buffer.py +297 -153
- maa/context.py +449 -34
- maa/controller.py +760 -113
- maa/custom_action.py +46 -3
- maa/custom_recognition.py +69 -11
- maa/define.py +539 -42
- maa/event_sink.py +103 -0
- maa/job.py +95 -36
- maa/library.py +182 -53
- maa/pipeline.py +509 -0
- maa/resource.py +598 -71
- maa/tasker.py +696 -156
- maa/toolkit.py +125 -165
- maafw-5.4.0b1.dist-info/METADATA +297 -0
- maafw-5.4.0b1.dist-info/RECORD +35 -0
- maafw-5.4.0b1.dist-info/WHEEL +4 -0
- MaaFw-2.1.0.dist-info/METADATA +0 -166
- MaaFw-2.1.0.dist-info/RECORD +0 -26
- MaaFw-2.1.0.dist-info/WHEEL +0 -4
- MaaFw-2.1.0.dist-info/top_level.txt +0 -1
- maa/bin/libMaaDbgControlUnit.so +0 -0
- maa/notification_handler.py +0 -191
- {MaaFw-2.1.0.dist-info → maafw-5.4.0b1.dist-info/licenses}/LICENSE.md +0 -0
maa/define.py
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import ctypes
|
|
2
2
|
import platform
|
|
3
3
|
from dataclasses import dataclass
|
|
4
|
-
from enum import IntEnum
|
|
4
|
+
from enum import IntEnum
|
|
5
5
|
from typing import List, Tuple, Union, Dict, Optional
|
|
6
6
|
|
|
7
7
|
import numpy
|
|
8
|
+
from strenum import StrEnum # For Python 3.9/3.10
|
|
8
9
|
|
|
9
10
|
MaaBool = ctypes.c_uint8
|
|
10
11
|
MaaSize = ctypes.c_size_t
|
|
@@ -15,7 +16,9 @@ MaaCtrlId = MaaId
|
|
|
15
16
|
MaaResId = MaaId
|
|
16
17
|
MaaTaskId = MaaId
|
|
17
18
|
MaaRecoId = MaaId
|
|
19
|
+
MaaActId = MaaId
|
|
18
20
|
MaaNodeId = MaaId
|
|
21
|
+
MaaSinkId = MaaId
|
|
19
22
|
MaaInvalidId = MaaId(0)
|
|
20
23
|
|
|
21
24
|
MaaStringBufferHandle = ctypes.c_void_p
|
|
@@ -52,7 +55,7 @@ MaaCtrlOption = MaaOption
|
|
|
52
55
|
MaaResOption = MaaOption
|
|
53
56
|
|
|
54
57
|
|
|
55
|
-
class MaaGlobalOptionEnum:
|
|
58
|
+
class MaaGlobalOptionEnum(IntEnum):
|
|
56
59
|
Invalid = 0
|
|
57
60
|
|
|
58
61
|
# Log dir
|
|
@@ -65,11 +68,12 @@ class MaaGlobalOptionEnum:
|
|
|
65
68
|
# value: bool, eg: true; val_size: sizeof(bool)
|
|
66
69
|
SaveDraw = 2
|
|
67
70
|
|
|
71
|
+
# Deprecated
|
|
68
72
|
# Dump all screenshots and actions
|
|
69
73
|
#
|
|
70
74
|
# Recording will evaluate to true if any of this or MaaCtrlOptionEnum::MaaCtrlOption_Recording
|
|
71
75
|
# is true. value: bool, eg: true; val_size: sizeof(bool)
|
|
72
|
-
Recording = 3
|
|
76
|
+
# Recording = 3
|
|
73
77
|
|
|
74
78
|
# The level of log output to stdout
|
|
75
79
|
#
|
|
@@ -87,8 +91,25 @@ class MaaGlobalOptionEnum:
|
|
|
87
91
|
# value: bool, eg: true; val_size: sizeof(bool)
|
|
88
92
|
DebugMode = 6
|
|
89
93
|
|
|
94
|
+
# Whether to save screenshot on error
|
|
95
|
+
#
|
|
96
|
+
# value: bool, eg: true; val_size: sizeof(bool)
|
|
97
|
+
SaveOnError = 7
|
|
98
|
+
|
|
99
|
+
# Image quality for draw images
|
|
100
|
+
#
|
|
101
|
+
# value: int, eg: 85; val_size: sizeof(int)
|
|
102
|
+
# default value is 85, range: [0, 100]
|
|
103
|
+
DrawQuality = 8
|
|
104
|
+
|
|
105
|
+
# Recognition image cache limit
|
|
106
|
+
#
|
|
107
|
+
# value: size_t, eg: 4096; val_size: sizeof(size_t)
|
|
108
|
+
# default value is 4096
|
|
109
|
+
RecoImageCacheLimit = 9
|
|
90
110
|
|
|
91
|
-
|
|
111
|
+
|
|
112
|
+
class MaaCtrlOptionEnum(IntEnum):
|
|
92
113
|
Invalid = 0
|
|
93
114
|
|
|
94
115
|
# Only one of long and short side can be set, and the other is automatically scaled according to the aspect ratio.
|
|
@@ -99,23 +120,48 @@ class MaaCtrlOptionEnum:
|
|
|
99
120
|
# value: int, eg: 1080; val_size: sizeof(int)
|
|
100
121
|
ScreenshotTargetShortSide = 2
|
|
101
122
|
|
|
123
|
+
# Screenshot use raw size without scaling.
|
|
124
|
+
# Please note that this option may cause incorrect coordinates on user devices with different resolutions if scaling is not performed.
|
|
125
|
+
# value: bool, eg: true; val_size: sizeof(bool)
|
|
126
|
+
ScreenshotUseRawSize = 3
|
|
127
|
+
|
|
128
|
+
# Deprecated
|
|
102
129
|
# Dump all screenshots and actions
|
|
103
130
|
# this option will || with MaaGlobalOptionEnum.Recording
|
|
104
131
|
# value: bool, eg: true; val_size: sizeof(bool)
|
|
105
|
-
Recording = 5
|
|
132
|
+
# Recording = 5
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class MaaInferenceDeviceEnum(IntEnum):
|
|
136
|
+
CPU = -2
|
|
137
|
+
Auto = -1
|
|
138
|
+
# and more gpu id or flag...
|
|
139
|
+
|
|
106
140
|
|
|
141
|
+
class MaaInferenceExecutionProviderEnum(IntEnum):
|
|
142
|
+
# I don't recommend setting up MaaResOption_InferenceDevice in this case,
|
|
143
|
+
# because you don't know which EP will be used on different user devices.
|
|
144
|
+
Auto = 0
|
|
107
145
|
|
|
108
|
-
#
|
|
109
|
-
|
|
110
|
-
# MaaInferenceDevice_CPU = -2,
|
|
111
|
-
# MaaInferenceDevice_Auto = -1,
|
|
112
|
-
# MaaInferenceDevice_GPU0 = 0,
|
|
113
|
-
# MaaInferenceDevice_GPU1 = 1,
|
|
114
|
-
# // and more gpu id...
|
|
115
|
-
# };
|
|
116
|
-
MaaInferenceDevice = ctypes.c_int32
|
|
146
|
+
# MaaResOption_InferenceDevice will not work.
|
|
147
|
+
CPU = 1
|
|
117
148
|
|
|
118
|
-
|
|
149
|
+
# MaaResOption_InferenceDevice will be used to set adapter id,
|
|
150
|
+
# It's from Win32 API `EnumAdapters1`.
|
|
151
|
+
DirectML = 2
|
|
152
|
+
|
|
153
|
+
# MaaResOption_InferenceDevice will be used to set coreml_flag,
|
|
154
|
+
# Reference to
|
|
155
|
+
# https://github.com/microsoft/onnxruntime/blob/main/include/onnxruntime/core/providers/coreml/coreml_provider_factory.h
|
|
156
|
+
# But you need to pay attention to the onnxruntime version we use, the latest flag may not be supported.
|
|
157
|
+
CoreML = 3
|
|
158
|
+
|
|
159
|
+
# MaaResOption_InferenceDevice will be used to set NVIDIA GPU ID
|
|
160
|
+
# TODO!
|
|
161
|
+
CUDA = 4
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
class MaaResOptionEnum(IntEnum):
|
|
119
165
|
Invalid = 0
|
|
120
166
|
|
|
121
167
|
# Use the specified inference device.
|
|
@@ -125,14 +171,38 @@ class MaaResOptionEnum:
|
|
|
125
171
|
# default value is MaaInferenceDevice_Auto
|
|
126
172
|
InferenceDevice = 1
|
|
127
173
|
|
|
174
|
+
# Use the specified inference execution provider
|
|
175
|
+
# Please set this option before loading the model.
|
|
176
|
+
#
|
|
177
|
+
# value: MaaInferenceExecutionProvider, eg: 0; val_size: sizeof(MaaInferenceExecutionProvider)
|
|
178
|
+
# default value is MaaInferenceExecutionProvider_Auto
|
|
179
|
+
InferenceExecutionProvider = 2
|
|
180
|
+
|
|
128
181
|
|
|
129
182
|
MaaAdbScreencapMethod = ctypes.c_uint64
|
|
130
183
|
|
|
131
184
|
|
|
132
|
-
class MaaAdbScreencapMethodEnum:
|
|
185
|
+
class MaaAdbScreencapMethodEnum(IntEnum):
|
|
133
186
|
"""
|
|
134
|
-
|
|
135
|
-
|
|
187
|
+
Adb screencap method flags.
|
|
188
|
+
|
|
189
|
+
Use bitwise OR to set the methods you need.
|
|
190
|
+
MaaFramework will test all provided methods and use the fastest available one.
|
|
191
|
+
|
|
192
|
+
Default: All methods except RawByNetcat, MinicapDirect, MinicapStream
|
|
193
|
+
|
|
194
|
+
Note: MinicapDirect and MinicapStream use lossy JPEG encoding, which may
|
|
195
|
+
significantly reduce template matching accuracy. Not recommended.
|
|
196
|
+
|
|
197
|
+
| Method | Speed | Compatibility | Encoding | Notes |
|
|
198
|
+
|-----------------------|------------|---------------|----------|-----------------------------------|
|
|
199
|
+
| EncodeToFileAndPull | Slow | High | Lossless | |
|
|
200
|
+
| Encode | Slow | High | Lossless | |
|
|
201
|
+
| RawWithGzip | Medium | High | Lossless | |
|
|
202
|
+
| RawByNetcat | Fast | Low | Lossless | |
|
|
203
|
+
| MinicapDirect | Fast | Low | Lossy | |
|
|
204
|
+
| MinicapStream | Very Fast | Low | Lossy | |
|
|
205
|
+
| EmulatorExtras | Very Fast | Low | Lossless | Emulators only: MuMu 12, LDPlayer 9 |
|
|
136
206
|
"""
|
|
137
207
|
|
|
138
208
|
Null = 0
|
|
@@ -146,17 +216,29 @@ class MaaAdbScreencapMethodEnum:
|
|
|
146
216
|
EmulatorExtras = 1 << 6
|
|
147
217
|
|
|
148
218
|
All = ~Null
|
|
149
|
-
Default = All & (~RawByNetcat) & (~MinicapDirect) & (~
|
|
219
|
+
Default = All & (~RawByNetcat) & (~MinicapDirect) & (~MinicapStream)
|
|
150
220
|
|
|
151
221
|
|
|
152
222
|
MaaAdbInputMethod = ctypes.c_uint64
|
|
153
223
|
|
|
154
224
|
|
|
155
|
-
class MaaAdbInputMethodEnum:
|
|
225
|
+
class MaaAdbInputMethodEnum(IntEnum):
|
|
156
226
|
"""
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
227
|
+
Adb input method flags.
|
|
228
|
+
|
|
229
|
+
Use bitwise OR to set the methods you need.
|
|
230
|
+
MaaFramework will select the first available method according to priority.
|
|
231
|
+
|
|
232
|
+
Priority (high to low): EmulatorExtras > Maatouch > MinitouchAndAdbKey > AdbShell
|
|
233
|
+
|
|
234
|
+
Default: All methods except EmulatorExtras
|
|
235
|
+
|
|
236
|
+
| Method | Speed | Compatibility | Notes |
|
|
237
|
+
|----------------------|-------|---------------|---------------------------------------|
|
|
238
|
+
| AdbShell | Slow | High | |
|
|
239
|
+
| MinitouchAndAdbKey | Fast | Medium | Key press still uses AdbShell |
|
|
240
|
+
| Maatouch | Fast | Medium | |
|
|
241
|
+
| EmulatorExtras | Fast | Low | Emulators only: MuMu 12 |
|
|
160
242
|
"""
|
|
161
243
|
|
|
162
244
|
Null = 0
|
|
@@ -173,31 +255,178 @@ class MaaAdbInputMethodEnum:
|
|
|
173
255
|
MaaWin32ScreencapMethod = ctypes.c_uint64
|
|
174
256
|
|
|
175
257
|
|
|
176
|
-
|
|
177
|
-
|
|
258
|
+
class MaaWin32ScreencapMethodEnum(IntEnum):
|
|
259
|
+
"""
|
|
260
|
+
Win32 screencap method.
|
|
261
|
+
|
|
262
|
+
No bitwise OR, select ONE method only.
|
|
263
|
+
|
|
264
|
+
No default value. Client should choose one as default.
|
|
265
|
+
|
|
266
|
+
Different applications use different rendering methods, there is no universal solution.
|
|
267
|
+
|
|
268
|
+
| Method | Speed | Compatibility | Require Admin | Background Support | Notes |
|
|
269
|
+
|-------------------------|-----------|---------------|---------------|--------------------|----------------------------------|
|
|
270
|
+
| GDI | Fast | Medium | No | No | |
|
|
271
|
+
| FramePool | Very Fast | Medium | No | Yes | Requires Windows 10 1903+ |
|
|
272
|
+
| DXGI_DesktopDup | Very Fast | Low | No | No | Desktop duplication (full screen)|
|
|
273
|
+
| DXGI_DesktopDup_Window | Very Fast | Low | No | No | Desktop duplication then crop |
|
|
274
|
+
| PrintWindow | Medium | Medium | No | Yes | |
|
|
275
|
+
| ScreenDC | Fast | High | No | No | |
|
|
276
|
+
|
|
277
|
+
Note: When a window is minimized on Windows, all screencap methods will fail.
|
|
278
|
+
Avoid minimizing the target window.
|
|
279
|
+
"""
|
|
280
|
+
|
|
178
281
|
Null = 0
|
|
179
282
|
|
|
180
283
|
GDI = 1
|
|
181
284
|
FramePool = 1 << 1
|
|
182
285
|
DXGI_DesktopDup = 1 << 2
|
|
286
|
+
DXGI_DesktopDup_Window = 1 << 3
|
|
287
|
+
PrintWindow = 1 << 4
|
|
288
|
+
ScreenDC = 1 << 5
|
|
183
289
|
|
|
184
290
|
|
|
185
291
|
MaaWin32InputMethod = ctypes.c_uint64
|
|
186
292
|
|
|
187
293
|
|
|
188
|
-
|
|
189
|
-
|
|
294
|
+
class MaaWin32InputMethodEnum(IntEnum):
|
|
295
|
+
"""
|
|
296
|
+
Win32 input method.
|
|
297
|
+
|
|
298
|
+
No bitwise OR, select ONE method only.
|
|
299
|
+
|
|
300
|
+
No default value. Client should choose one as default.
|
|
301
|
+
|
|
302
|
+
Different applications process input differently, there is no universal solution.
|
|
303
|
+
|
|
304
|
+
| Method | Compatibility | Require Admin | Seize Mouse | Background Support | Notes |
|
|
305
|
+
|------------------------------|---------------|---------------|--------------|--------------------|-------------------------------------------------------------|
|
|
306
|
+
| Seize | High | No | Yes | No | |
|
|
307
|
+
| SendMessage | Medium | Maybe | No | Yes | |
|
|
308
|
+
| PostMessage | Medium | Maybe | No | Yes | |
|
|
309
|
+
| LegacyEvent | Low | No | Yes | No | |
|
|
310
|
+
| PostThreadMessage | Low | Maybe | No | Yes | |
|
|
311
|
+
| SendMessageWithCursorPos | Medium | Maybe | Briefly | Yes | Designed for apps that check real cursor position |
|
|
312
|
+
| PostMessageWithCursorPos | Medium | Maybe | Briefly | Yes | Designed for apps that check real cursor position |
|
|
313
|
+
|
|
314
|
+
Note:
|
|
315
|
+
- Admin rights mainly depend on the target application's privilege level.
|
|
316
|
+
If the target runs as admin, MaaFramework should also run as admin for compatibility.
|
|
317
|
+
- "WithCursorPos" methods briefly move the cursor to target position, send message,
|
|
318
|
+
then restore cursor position. This "briefly" seizes the mouse but won't block user operations.
|
|
319
|
+
"""
|
|
320
|
+
|
|
190
321
|
Null = 0
|
|
191
322
|
|
|
192
323
|
Seize = 1
|
|
193
324
|
SendMessage = 1 << 1
|
|
325
|
+
PostMessage = 1 << 2
|
|
326
|
+
LegacyEvent = 1 << 3
|
|
327
|
+
PostThreadMessage = 1 << 4
|
|
328
|
+
SendMessageWithCursorPos = 1 << 5
|
|
329
|
+
PostMessageWithCursorPos = 1 << 6
|
|
194
330
|
|
|
195
331
|
|
|
196
332
|
# No bitwise OR, just set it
|
|
197
333
|
MaaDbgControllerType = ctypes.c_uint64
|
|
198
334
|
|
|
335
|
+
# No bitwise OR, just set it
|
|
336
|
+
MaaGamepadType = ctypes.c_uint64
|
|
337
|
+
|
|
199
338
|
|
|
200
|
-
class
|
|
339
|
+
class MaaGamepadTypeEnum(IntEnum):
|
|
340
|
+
"""
|
|
341
|
+
Virtual gamepad type for GamepadController (Windows only).
|
|
342
|
+
|
|
343
|
+
No bitwise OR, select ONE type only.
|
|
344
|
+
|
|
345
|
+
Requires ViGEm Bus Driver to be installed.
|
|
346
|
+
|
|
347
|
+
| Type | Description |
|
|
348
|
+
|-------------|---------------------------------------|
|
|
349
|
+
| Xbox360 | Microsoft Xbox 360 Controller (wired) |
|
|
350
|
+
| DualShock4 | Sony DualShock 4 Controller (wired) |
|
|
351
|
+
"""
|
|
352
|
+
|
|
353
|
+
Xbox360 = 0
|
|
354
|
+
DualShock4 = 1
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
class MaaGamepadButtonEnum(IntEnum):
|
|
358
|
+
"""
|
|
359
|
+
Gamepad button flags (XUSB protocol values).
|
|
360
|
+
|
|
361
|
+
Use bitwise OR to combine multiple buttons.
|
|
362
|
+
DS4 face buttons are aliases to Xbox face buttons.
|
|
363
|
+
"""
|
|
364
|
+
|
|
365
|
+
# D-pad
|
|
366
|
+
DPAD_UP = 0x0001
|
|
367
|
+
DPAD_DOWN = 0x0002
|
|
368
|
+
DPAD_LEFT = 0x0004
|
|
369
|
+
DPAD_RIGHT = 0x0008
|
|
370
|
+
|
|
371
|
+
# Control buttons
|
|
372
|
+
START = 0x0010
|
|
373
|
+
BACK = 0x0020
|
|
374
|
+
LEFT_THUMB = 0x0040 # L3
|
|
375
|
+
RIGHT_THUMB = 0x0080 # R3
|
|
376
|
+
|
|
377
|
+
# Shoulder buttons
|
|
378
|
+
LB = 0x0100 # Left Bumper / L1
|
|
379
|
+
RB = 0x0200 # Right Bumper / R1
|
|
380
|
+
|
|
381
|
+
# Guide button
|
|
382
|
+
GUIDE = 0x0400
|
|
383
|
+
|
|
384
|
+
# Face buttons (Xbox layout)
|
|
385
|
+
A = 0x1000
|
|
386
|
+
B = 0x2000
|
|
387
|
+
X = 0x4000
|
|
388
|
+
Y = 0x8000
|
|
389
|
+
|
|
390
|
+
# DS4 face buttons (aliases to Xbox buttons)
|
|
391
|
+
CROSS = A
|
|
392
|
+
CIRCLE = B
|
|
393
|
+
SQUARE = X
|
|
394
|
+
TRIANGLE = Y
|
|
395
|
+
L1 = LB
|
|
396
|
+
R1 = RB
|
|
397
|
+
L3 = LEFT_THUMB
|
|
398
|
+
R3 = RIGHT_THUMB
|
|
399
|
+
OPTIONS = START
|
|
400
|
+
SHARE = BACK
|
|
401
|
+
|
|
402
|
+
# DS4 special buttons (unique values)
|
|
403
|
+
PS = 0x10000
|
|
404
|
+
TOUCHPAD = 0x20000
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
class MaaGamepadContactEnum(IntEnum):
|
|
408
|
+
"""
|
|
409
|
+
Gamepad contact (analog stick or trigger) mapping for touch_down/touch_move/touch_up.
|
|
410
|
+
"""
|
|
411
|
+
|
|
412
|
+
LEFT_STICK = 0 # x: -32768~32767, y: -32768~32767
|
|
413
|
+
RIGHT_STICK = 1 # x: -32768~32767, y: -32768~32767
|
|
414
|
+
LEFT_TRIGGER = 2 # pressure: 0~255
|
|
415
|
+
RIGHT_TRIGGER = 3 # pressure: 0~255
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
MaaControllerFeature = ctypes.c_uint64
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
# Use bitwise OR to set the features you need
|
|
422
|
+
class MaaControllerFeatureEnum(IntEnum):
|
|
423
|
+
Null = 0
|
|
424
|
+
|
|
425
|
+
UseMouseDownAndUpInsteadOfClick = 1
|
|
426
|
+
UseKeyboardDownAndUpInsteadOfClick = 1 << 1
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
class MaaDbgControllerTypeEnum(IntEnum):
|
|
201
430
|
Null = 0
|
|
202
431
|
|
|
203
432
|
CarouselImage = 1
|
|
@@ -206,15 +435,15 @@ class MaaDbgControllerTypeEnum:
|
|
|
206
435
|
|
|
207
436
|
FUNCTYPE = ctypes.WINFUNCTYPE if (platform.system() == "Windows") else ctypes.CFUNCTYPE
|
|
208
437
|
|
|
209
|
-
|
|
210
|
-
None, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_void_p
|
|
438
|
+
MaaEventCallback = FUNCTYPE(
|
|
439
|
+
None, ctypes.c_void_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_void_p
|
|
211
440
|
)
|
|
212
441
|
|
|
213
442
|
MaaCustomRecognitionCallback = FUNCTYPE(
|
|
214
443
|
MaaBool, # return value
|
|
215
444
|
MaaContextHandle, # context
|
|
216
445
|
MaaTaskId, # task_id
|
|
217
|
-
ctypes.c_char_p, #
|
|
446
|
+
ctypes.c_char_p, # node_name
|
|
218
447
|
ctypes.c_char_p, # custom_recognition_name
|
|
219
448
|
ctypes.c_char_p, # custom_recognition_param
|
|
220
449
|
MaaImageBufferHandle, # image
|
|
@@ -228,7 +457,7 @@ MaaCustomActionCallback = FUNCTYPE(
|
|
|
228
457
|
MaaBool, # return value
|
|
229
458
|
MaaContextHandle, # context
|
|
230
459
|
MaaTaskId, # task_id
|
|
231
|
-
ctypes.c_char_p, #
|
|
460
|
+
ctypes.c_char_p, # node_name
|
|
232
461
|
ctypes.c_char_p, # custom_action_name
|
|
233
462
|
ctypes.c_char_p, #
|
|
234
463
|
MaaRecoId, # reco_id
|
|
@@ -242,17 +471,27 @@ MaaToolkitAdbDeviceHandle = ctypes.c_void_p
|
|
|
242
471
|
MaaToolkitDesktopWindowListHandle = ctypes.c_void_p
|
|
243
472
|
MaaToolkitDesktopWindowHandle = ctypes.c_void_p
|
|
244
473
|
|
|
474
|
+
MaaAgentClientHandle = ctypes.c_void_p
|
|
475
|
+
|
|
245
476
|
|
|
246
477
|
class MaaCustomControllerCallbacks(ctypes.Structure):
|
|
247
478
|
ConnectFunc = FUNCTYPE(
|
|
248
479
|
MaaBool,
|
|
249
480
|
ctypes.c_void_p,
|
|
250
481
|
)
|
|
482
|
+
ConnectedFunc = FUNCTYPE(
|
|
483
|
+
MaaBool,
|
|
484
|
+
ctypes.c_void_p,
|
|
485
|
+
)
|
|
251
486
|
RequestUuidFunc = FUNCTYPE(
|
|
252
487
|
MaaBool,
|
|
253
488
|
ctypes.c_void_p,
|
|
254
489
|
MaaStringBufferHandle,
|
|
255
490
|
)
|
|
491
|
+
GetFeaturesFunc = FUNCTYPE(
|
|
492
|
+
MaaControllerFeature,
|
|
493
|
+
ctypes.c_void_p,
|
|
494
|
+
)
|
|
256
495
|
StartAppFunc = FUNCTYPE(
|
|
257
496
|
MaaBool,
|
|
258
497
|
ctypes.c_char_p,
|
|
@@ -304,7 +543,7 @@ class MaaCustomControllerCallbacks(ctypes.Structure):
|
|
|
304
543
|
ctypes.c_int32,
|
|
305
544
|
ctypes.c_void_p,
|
|
306
545
|
)
|
|
307
|
-
|
|
546
|
+
ClickKeyFunc = FUNCTYPE(
|
|
308
547
|
MaaBool,
|
|
309
548
|
ctypes.c_int32,
|
|
310
549
|
ctypes.c_void_p,
|
|
@@ -314,9 +553,27 @@ class MaaCustomControllerCallbacks(ctypes.Structure):
|
|
|
314
553
|
ctypes.c_char_p,
|
|
315
554
|
ctypes.c_void_p,
|
|
316
555
|
)
|
|
556
|
+
KeyDownFunc = FUNCTYPE(
|
|
557
|
+
MaaBool,
|
|
558
|
+
ctypes.c_int32,
|
|
559
|
+
ctypes.c_void_p,
|
|
560
|
+
)
|
|
561
|
+
KeyUpFunc = FUNCTYPE(
|
|
562
|
+
MaaBool,
|
|
563
|
+
ctypes.c_int32,
|
|
564
|
+
ctypes.c_void_p,
|
|
565
|
+
)
|
|
566
|
+
ScrollFunc = FUNCTYPE(
|
|
567
|
+
MaaBool,
|
|
568
|
+
ctypes.c_int32,
|
|
569
|
+
ctypes.c_int32,
|
|
570
|
+
ctypes.c_void_p,
|
|
571
|
+
)
|
|
317
572
|
_fields_ = [
|
|
318
573
|
("connect", ConnectFunc),
|
|
574
|
+
("connected", ConnectedFunc),
|
|
319
575
|
("request_uuid", RequestUuidFunc),
|
|
576
|
+
("get_features", GetFeaturesFunc),
|
|
320
577
|
("start_app", StartAppFunc),
|
|
321
578
|
("stop_app", StopAppFunc),
|
|
322
579
|
("screencap", ScreencapFunc),
|
|
@@ -325,11 +582,81 @@ class MaaCustomControllerCallbacks(ctypes.Structure):
|
|
|
325
582
|
("touch_down", TouchDownFunc),
|
|
326
583
|
("touch_move", TouchMoveFunc),
|
|
327
584
|
("touch_up", TouchUpFunc),
|
|
328
|
-
("
|
|
585
|
+
("click_key", ClickKeyFunc),
|
|
329
586
|
("input_text", InputTextFunc),
|
|
587
|
+
("key_down", KeyDownFunc),
|
|
588
|
+
("key_up", KeyUpFunc),
|
|
589
|
+
("scroll", ScrollFunc),
|
|
330
590
|
]
|
|
331
591
|
|
|
332
592
|
|
|
593
|
+
class Status:
|
|
594
|
+
_status: MaaStatusEnum
|
|
595
|
+
|
|
596
|
+
def __init__(self, status: Union[MaaStatus, MaaStatusEnum, int]):
|
|
597
|
+
if isinstance(status, MaaStatus):
|
|
598
|
+
self._status = MaaStatusEnum(status.value)
|
|
599
|
+
elif isinstance(status, MaaStatusEnum):
|
|
600
|
+
self._status = status
|
|
601
|
+
else:
|
|
602
|
+
self._status = MaaStatusEnum(status)
|
|
603
|
+
|
|
604
|
+
@property
|
|
605
|
+
def done(self) -> bool:
|
|
606
|
+
return self._status in [MaaStatusEnum.succeeded, MaaStatusEnum.failed]
|
|
607
|
+
|
|
608
|
+
@property
|
|
609
|
+
def succeeded(self) -> bool:
|
|
610
|
+
return self._status == MaaStatusEnum.succeeded
|
|
611
|
+
|
|
612
|
+
@property
|
|
613
|
+
def failed(self) -> bool:
|
|
614
|
+
return self._status == MaaStatusEnum.failed
|
|
615
|
+
|
|
616
|
+
@property
|
|
617
|
+
def pending(self) -> bool:
|
|
618
|
+
return self._status == MaaStatusEnum.pending
|
|
619
|
+
|
|
620
|
+
@property
|
|
621
|
+
def running(self) -> bool:
|
|
622
|
+
return self._status == MaaStatusEnum.running
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
@dataclass
|
|
626
|
+
class Point:
|
|
627
|
+
x: int = 0
|
|
628
|
+
y: int = 0
|
|
629
|
+
|
|
630
|
+
def __add__(
|
|
631
|
+
self,
|
|
632
|
+
other: Union[
|
|
633
|
+
"Point",
|
|
634
|
+
Tuple[int, int],
|
|
635
|
+
List[int],
|
|
636
|
+
],
|
|
637
|
+
):
|
|
638
|
+
if (
|
|
639
|
+
isinstance(other, Point)
|
|
640
|
+
or isinstance(other, tuple)
|
|
641
|
+
or (isinstance(other, list) and len(other) == 2)
|
|
642
|
+
):
|
|
643
|
+
x1, y1 = self
|
|
644
|
+
x2, y2 = other
|
|
645
|
+
return Point(
|
|
646
|
+
x1 + x2,
|
|
647
|
+
y1 + y2,
|
|
648
|
+
)
|
|
649
|
+
|
|
650
|
+
raise TypeError(f"Cannot add {type(other).__name__} to Point")
|
|
651
|
+
|
|
652
|
+
def __iter__(self):
|
|
653
|
+
yield self.x
|
|
654
|
+
yield self.y
|
|
655
|
+
|
|
656
|
+
def __getitem__(self, key):
|
|
657
|
+
return list(self)[key]
|
|
658
|
+
|
|
659
|
+
|
|
333
660
|
@dataclass
|
|
334
661
|
class Rect:
|
|
335
662
|
x: int = 0
|
|
@@ -368,12 +695,15 @@ class Rect:
|
|
|
368
695
|
yield self.h
|
|
369
696
|
|
|
370
697
|
def __getitem__(self, key):
|
|
371
|
-
return self
|
|
698
|
+
return list(self)[key]
|
|
372
699
|
|
|
373
|
-
@property
|
|
374
|
-
def roi(self):
|
|
375
|
-
return list(self)
|
|
376
700
|
|
|
701
|
+
PointType = Union[
|
|
702
|
+
Point,
|
|
703
|
+
List[int],
|
|
704
|
+
numpy.ndarray,
|
|
705
|
+
Tuple[int, int],
|
|
706
|
+
]
|
|
377
707
|
|
|
378
708
|
RectType = Union[
|
|
379
709
|
Rect,
|
|
@@ -383,7 +713,7 @@ RectType = Union[
|
|
|
383
713
|
]
|
|
384
714
|
|
|
385
715
|
|
|
386
|
-
class AlgorithmEnum(
|
|
716
|
+
class AlgorithmEnum(StrEnum):
|
|
387
717
|
DirectHit = "DirectHit"
|
|
388
718
|
TemplateMatch = "TemplateMatch"
|
|
389
719
|
FeatureMatch = "FeatureMatch"
|
|
@@ -391,6 +721,31 @@ class AlgorithmEnum(str, Enum):
|
|
|
391
721
|
OCR = "OCR"
|
|
392
722
|
NeuralNetworkClassify = "NeuralNetworkClassify"
|
|
393
723
|
NeuralNetworkDetect = "NeuralNetworkDetect"
|
|
724
|
+
And = "And"
|
|
725
|
+
Or = "Or"
|
|
726
|
+
Custom = "Custom"
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
class ActionEnum(StrEnum):
|
|
730
|
+
DoNothing = "DoNothing"
|
|
731
|
+
Click = "Click"
|
|
732
|
+
LongPress = "LongPress"
|
|
733
|
+
Swipe = "Swipe"
|
|
734
|
+
MultiSwipe = "MultiSwipe"
|
|
735
|
+
ClickKey = "ClickKey"
|
|
736
|
+
LongPressKey = "LongPressKey"
|
|
737
|
+
InputText = "InputText"
|
|
738
|
+
StartApp = "StartApp"
|
|
739
|
+
StopApp = "StopApp"
|
|
740
|
+
Scroll = "Scroll"
|
|
741
|
+
TouchDown = "TouchDown"
|
|
742
|
+
TouchMove = "TouchMove"
|
|
743
|
+
TouchUp = "TouchUp"
|
|
744
|
+
KeyDown = "KeyDown"
|
|
745
|
+
KeyUp = "KeyUp"
|
|
746
|
+
StopTask = "StopTask"
|
|
747
|
+
Command = "Command"
|
|
748
|
+
Shell = "Shell"
|
|
394
749
|
Custom = "Custom"
|
|
395
750
|
|
|
396
751
|
|
|
@@ -436,6 +791,20 @@ class CustomRecognitionResult:
|
|
|
436
791
|
detail: Union[str, Dict]
|
|
437
792
|
|
|
438
793
|
|
|
794
|
+
@dataclass
|
|
795
|
+
class AndRecognitionResult:
|
|
796
|
+
"""And 算法识别结果,包含所有子识别的完整详情"""
|
|
797
|
+
|
|
798
|
+
sub_results: List["RecognitionDetail"]
|
|
799
|
+
|
|
800
|
+
|
|
801
|
+
@dataclass
|
|
802
|
+
class OrRecognitionResult:
|
|
803
|
+
"""Or 算法识别结果,包含已执行子识别的完整详情"""
|
|
804
|
+
|
|
805
|
+
sub_results: List["RecognitionDetail"]
|
|
806
|
+
|
|
807
|
+
|
|
439
808
|
RecognitionResult = Union[
|
|
440
809
|
TemplateMatchResult,
|
|
441
810
|
FeatureMatchResult,
|
|
@@ -443,6 +812,8 @@ RecognitionResult = Union[
|
|
|
443
812
|
OCRResult,
|
|
444
813
|
NeuralNetworkClassifyResult,
|
|
445
814
|
NeuralNetworkDetectResult,
|
|
815
|
+
AndRecognitionResult,
|
|
816
|
+
OrRecognitionResult,
|
|
446
817
|
CustomRecognitionResult,
|
|
447
818
|
]
|
|
448
819
|
|
|
@@ -454,6 +825,8 @@ AlgorithmResultDict = {
|
|
|
454
825
|
AlgorithmEnum.OCR: OCRResult,
|
|
455
826
|
AlgorithmEnum.NeuralNetworkClassify: NeuralNetworkClassifyResult,
|
|
456
827
|
AlgorithmEnum.NeuralNetworkDetect: NeuralNetworkDetectResult,
|
|
828
|
+
AlgorithmEnum.And: AndRecognitionResult,
|
|
829
|
+
AlgorithmEnum.Or: OrRecognitionResult,
|
|
457
830
|
AlgorithmEnum.Custom: CustomRecognitionResult,
|
|
458
831
|
}
|
|
459
832
|
|
|
@@ -462,11 +835,12 @@ AlgorithmResultDict = {
|
|
|
462
835
|
class RecognitionDetail:
|
|
463
836
|
reco_id: int
|
|
464
837
|
name: str
|
|
465
|
-
algorithm: AlgorithmEnum
|
|
838
|
+
algorithm: Union[AlgorithmEnum, str]
|
|
839
|
+
hit: bool
|
|
466
840
|
box: Optional[Rect]
|
|
467
841
|
|
|
468
842
|
all_results: List[RecognitionResult]
|
|
469
|
-
|
|
843
|
+
filtered_results: List[RecognitionResult]
|
|
470
844
|
best_result: Optional[RecognitionResult]
|
|
471
845
|
|
|
472
846
|
raw_detail: Dict
|
|
@@ -474,11 +848,133 @@ class RecognitionDetail:
|
|
|
474
848
|
draw_images: List[numpy.ndarray] # only valid in debug mode
|
|
475
849
|
|
|
476
850
|
|
|
851
|
+
@dataclass
|
|
852
|
+
class ClickActionResult:
|
|
853
|
+
point: Point
|
|
854
|
+
contact: int
|
|
855
|
+
|
|
856
|
+
|
|
857
|
+
@dataclass
|
|
858
|
+
class LongPressActionResult:
|
|
859
|
+
point: Point
|
|
860
|
+
duration: int
|
|
861
|
+
contact: int
|
|
862
|
+
|
|
863
|
+
|
|
864
|
+
@dataclass
|
|
865
|
+
class SwipeActionResult:
|
|
866
|
+
begin: Point
|
|
867
|
+
end: List[Point]
|
|
868
|
+
end_hold: List[int]
|
|
869
|
+
duration: List[int]
|
|
870
|
+
only_hover: bool
|
|
871
|
+
starting: int
|
|
872
|
+
contact: int
|
|
873
|
+
|
|
874
|
+
|
|
875
|
+
@dataclass
|
|
876
|
+
class MultiSwipeActionResult:
|
|
877
|
+
swipes: List[SwipeActionResult]
|
|
878
|
+
|
|
879
|
+
|
|
880
|
+
@dataclass
|
|
881
|
+
class ClickKeyActionResult:
|
|
882
|
+
keycode: List[int]
|
|
883
|
+
|
|
884
|
+
|
|
885
|
+
@dataclass
|
|
886
|
+
class LongPressKeyActionResult:
|
|
887
|
+
keycode: List[int]
|
|
888
|
+
duration: int
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
@dataclass
|
|
892
|
+
class InputTextActionResult:
|
|
893
|
+
text: str
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
@dataclass
|
|
897
|
+
class AppActionResult:
|
|
898
|
+
package: str
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
@dataclass
|
|
902
|
+
class ScrollActionResult:
|
|
903
|
+
dx: int
|
|
904
|
+
dy: int
|
|
905
|
+
|
|
906
|
+
|
|
907
|
+
@dataclass
|
|
908
|
+
class TouchActionResult:
|
|
909
|
+
contact: int
|
|
910
|
+
point: Point
|
|
911
|
+
pressure: int
|
|
912
|
+
|
|
913
|
+
|
|
914
|
+
@dataclass
|
|
915
|
+
class ShellActionResult:
|
|
916
|
+
cmd: str
|
|
917
|
+
timeout: int
|
|
918
|
+
success: bool
|
|
919
|
+
output: str
|
|
920
|
+
|
|
921
|
+
|
|
922
|
+
ActionResult = Union[
|
|
923
|
+
ClickActionResult,
|
|
924
|
+
LongPressActionResult,
|
|
925
|
+
SwipeActionResult,
|
|
926
|
+
MultiSwipeActionResult,
|
|
927
|
+
ClickKeyActionResult,
|
|
928
|
+
LongPressKeyActionResult,
|
|
929
|
+
InputTextActionResult,
|
|
930
|
+
AppActionResult,
|
|
931
|
+
ScrollActionResult,
|
|
932
|
+
TouchActionResult,
|
|
933
|
+
ShellActionResult,
|
|
934
|
+
None,
|
|
935
|
+
]
|
|
936
|
+
|
|
937
|
+
ActionResultDict = {
|
|
938
|
+
ActionEnum.DoNothing: None,
|
|
939
|
+
ActionEnum.Click: ClickActionResult,
|
|
940
|
+
ActionEnum.LongPress: LongPressActionResult,
|
|
941
|
+
ActionEnum.Swipe: SwipeActionResult,
|
|
942
|
+
ActionEnum.MultiSwipe: MultiSwipeActionResult,
|
|
943
|
+
ActionEnum.ClickKey: ClickKeyActionResult,
|
|
944
|
+
ActionEnum.LongPressKey: LongPressKeyActionResult,
|
|
945
|
+
ActionEnum.InputText: InputTextActionResult,
|
|
946
|
+
ActionEnum.StartApp: AppActionResult,
|
|
947
|
+
ActionEnum.StopApp: AppActionResult,
|
|
948
|
+
ActionEnum.Scroll: ScrollActionResult,
|
|
949
|
+
ActionEnum.TouchDown: TouchActionResult,
|
|
950
|
+
ActionEnum.TouchMove: TouchActionResult,
|
|
951
|
+
ActionEnum.TouchUp: TouchActionResult,
|
|
952
|
+
ActionEnum.KeyDown: ClickKeyActionResult,
|
|
953
|
+
ActionEnum.KeyUp: ClickKeyActionResult,
|
|
954
|
+
ActionEnum.StopTask: None,
|
|
955
|
+
ActionEnum.Command: None,
|
|
956
|
+
ActionEnum.Shell: ShellActionResult,
|
|
957
|
+
ActionEnum.Custom: None,
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
@dataclass
|
|
962
|
+
class ActionDetail:
|
|
963
|
+
action_id: int
|
|
964
|
+
name: str
|
|
965
|
+
action: Union[ActionEnum, str]
|
|
966
|
+
box: Rect
|
|
967
|
+
success: bool
|
|
968
|
+
result: Optional[ActionResult]
|
|
969
|
+
raw_detail: Dict
|
|
970
|
+
|
|
971
|
+
|
|
477
972
|
@dataclass
|
|
478
973
|
class NodeDetail:
|
|
479
974
|
node_id: int
|
|
480
975
|
name: str
|
|
481
|
-
recognition: RecognitionDetail
|
|
976
|
+
recognition: Optional[RecognitionDetail]
|
|
977
|
+
action: Optional[ActionDetail]
|
|
482
978
|
completed: bool
|
|
483
979
|
|
|
484
980
|
|
|
@@ -487,6 +983,7 @@ class TaskDetail:
|
|
|
487
983
|
task_id: int
|
|
488
984
|
entry: str
|
|
489
985
|
nodes: List[NodeDetail]
|
|
986
|
+
status: Status
|
|
490
987
|
|
|
491
988
|
|
|
492
989
|
class LoggingLevelEnum(IntEnum):
|