MaaFw 4.4.0b1__py3-none-manylinux2014_x86_64.whl → 5.4.0__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.
Potentially problematic release.
This version of MaaFw might be problematic. Click here for more details.
- maa/agent/agent_server.py +221 -3
- maa/agent_client.py +170 -2
- 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/libonnxruntime.so.1 +0 -0
- maa/bin/{libopencv_world4.so.408 → libopencv_world4.so.411} +0 -0
- maa/bin/libunwind.so.1 +0 -0
- maa/bin/plugins/libMaaPluginDemo.so +0 -0
- maa/buffer.py +168 -0
- maa/context.py +402 -10
- maa/controller.py +685 -44
- maa/custom_action.py +43 -0
- maa/custom_recognition.py +61 -9
- maa/define.py +450 -20
- maa/event_sink.py +103 -0
- maa/job.py +77 -1
- maa/library.py +118 -50
- maa/pipeline.py +509 -0
- maa/resource.py +430 -21
- maa/tasker.py +630 -90
- maa/toolkit.py +52 -91
- {maafw-4.4.0b1.dist-info → maafw-5.4.0.dist-info}/METADATA +90 -45
- maafw-5.4.0.dist-info/RECORD +35 -0
- {maafw-4.4.0b1.dist-info → maafw-5.4.0.dist-info}/WHEEL +1 -1
- maa/bin/libMaaDbgControlUnit.so +0 -0
- maa/notification_handler.py +0 -197
- maafw-4.4.0b1.dist-info/RECORD +0 -30
- {maafw-4.4.0b1.dist-info → maafw-5.4.0.dist-info}/licenses/LICENSE.md +0 -0
maa/buffer.py
CHANGED
|
@@ -9,6 +9,12 @@ from .library import Library
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class StringBuffer:
|
|
12
|
+
"""字符串缓冲区 / String buffer
|
|
13
|
+
|
|
14
|
+
用于在 Python 和 C API 之间传递字符串数据。
|
|
15
|
+
Used to pass string data between Python and C API.
|
|
16
|
+
"""
|
|
17
|
+
|
|
12
18
|
_handle: MaaStringBufferHandle
|
|
13
19
|
_own: bool
|
|
14
20
|
|
|
@@ -30,11 +36,24 @@ class StringBuffer:
|
|
|
30
36
|
Library.framework().MaaStringBufferDestroy(self._handle)
|
|
31
37
|
|
|
32
38
|
def get(self) -> str:
|
|
39
|
+
"""获取缓冲区内容 / Get buffer content
|
|
40
|
+
|
|
41
|
+
Returns:
|
|
42
|
+
str: 字符串内容 / String content
|
|
43
|
+
"""
|
|
33
44
|
buff = Library.framework().MaaStringBufferGet(self._handle)
|
|
34
45
|
sz = Library.framework().MaaStringBufferSize(self._handle)
|
|
35
46
|
return ctypes.string_at(buff, sz).decode()
|
|
36
47
|
|
|
37
48
|
def set(self, value: Union[str, bytes]) -> bool:
|
|
49
|
+
"""设置缓冲区内容 / Set buffer content
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
value: 字符串或字节数据 / String or bytes data
|
|
53
|
+
|
|
54
|
+
Returns:
|
|
55
|
+
bool: 是否成功 / Whether successful
|
|
56
|
+
"""
|
|
38
57
|
if isinstance(value, str):
|
|
39
58
|
value = value.encode()
|
|
40
59
|
return bool(
|
|
@@ -43,9 +62,19 @@ class StringBuffer:
|
|
|
43
62
|
|
|
44
63
|
@property
|
|
45
64
|
def empty(self) -> bool:
|
|
65
|
+
"""判断缓冲区是否为空 / Check if buffer is empty
|
|
66
|
+
|
|
67
|
+
Returns:
|
|
68
|
+
bool: 是否为空 / Whether empty
|
|
69
|
+
"""
|
|
46
70
|
return bool(Library.framework().MaaStringBufferIsEmpty(self._handle))
|
|
47
71
|
|
|
48
72
|
def clear(self) -> bool:
|
|
73
|
+
"""清空缓冲区 / Clear buffer
|
|
74
|
+
|
|
75
|
+
Returns:
|
|
76
|
+
bool: 是否成功 / Whether successful
|
|
77
|
+
"""
|
|
49
78
|
return bool(Library.framework().MaaStringBufferClear(self._handle))
|
|
50
79
|
|
|
51
80
|
_api_properties_initialized: bool = False
|
|
@@ -89,6 +118,12 @@ class StringBuffer:
|
|
|
89
118
|
|
|
90
119
|
|
|
91
120
|
class StringListBuffer:
|
|
121
|
+
"""字符串列表缓冲区 / String list buffer
|
|
122
|
+
|
|
123
|
+
用于在 Python 和 C API 之间传递字符串列表数据。
|
|
124
|
+
Used to pass string list data between Python and C API.
|
|
125
|
+
"""
|
|
126
|
+
|
|
92
127
|
_handle: MaaStringListBufferHandle
|
|
93
128
|
_own: bool
|
|
94
129
|
|
|
@@ -110,6 +145,11 @@ class StringListBuffer:
|
|
|
110
145
|
Library.framework().MaaStringListBufferDestroy(self._handle)
|
|
111
146
|
|
|
112
147
|
def get(self) -> List[str]:
|
|
148
|
+
"""获取字符串列表 / Get string list
|
|
149
|
+
|
|
150
|
+
Returns:
|
|
151
|
+
List[str]: 字符串列表 / String list
|
|
152
|
+
"""
|
|
113
153
|
count = Library.framework().MaaStringListBufferSize(self._handle)
|
|
114
154
|
result = []
|
|
115
155
|
for i in range(count):
|
|
@@ -119,6 +159,14 @@ class StringListBuffer:
|
|
|
119
159
|
return result
|
|
120
160
|
|
|
121
161
|
def set(self, value: List[str]) -> bool:
|
|
162
|
+
"""设置字符串列表 / Set string list
|
|
163
|
+
|
|
164
|
+
Args:
|
|
165
|
+
value: 字符串列表 / String list
|
|
166
|
+
|
|
167
|
+
Returns:
|
|
168
|
+
bool: 是否成功 / Whether successful
|
|
169
|
+
"""
|
|
122
170
|
self.clear()
|
|
123
171
|
for s in value:
|
|
124
172
|
if not self.append(s):
|
|
@@ -126,6 +174,14 @@ class StringListBuffer:
|
|
|
126
174
|
return True
|
|
127
175
|
|
|
128
176
|
def append(self, value: str) -> bool:
|
|
177
|
+
"""追加字符串 / Append string
|
|
178
|
+
|
|
179
|
+
Args:
|
|
180
|
+
value: 要追加的字符串 / String to append
|
|
181
|
+
|
|
182
|
+
Returns:
|
|
183
|
+
bool: 是否成功 / Whether successful
|
|
184
|
+
"""
|
|
129
185
|
buff = StringBuffer()
|
|
130
186
|
buff.set(value)
|
|
131
187
|
return bool(
|
|
@@ -133,9 +189,22 @@ class StringListBuffer:
|
|
|
133
189
|
)
|
|
134
190
|
|
|
135
191
|
def remove(self, index: int) -> bool:
|
|
192
|
+
"""移除指定索引的字符串 / Remove string at index
|
|
193
|
+
|
|
194
|
+
Args:
|
|
195
|
+
index: 要移除的索引 / Index to remove
|
|
196
|
+
|
|
197
|
+
Returns:
|
|
198
|
+
bool: 是否成功 / Whether successful
|
|
199
|
+
"""
|
|
136
200
|
return bool(Library.framework().MaaStringListBufferRemove(self._handle, index))
|
|
137
201
|
|
|
138
202
|
def clear(self) -> bool:
|
|
203
|
+
"""清空列表 / Clear list
|
|
204
|
+
|
|
205
|
+
Returns:
|
|
206
|
+
bool: 是否成功 / Whether successful
|
|
207
|
+
"""
|
|
139
208
|
return bool(Library.framework().MaaStringListBufferClear(self._handle))
|
|
140
209
|
|
|
141
210
|
_api_properties_initialized: bool = False
|
|
@@ -191,6 +260,12 @@ class StringListBuffer:
|
|
|
191
260
|
|
|
192
261
|
|
|
193
262
|
class ImageBuffer:
|
|
263
|
+
"""图像缓冲区 / Image buffer
|
|
264
|
+
|
|
265
|
+
用于在 Python 和 C API 之间传递图像数据。图像格式为 BGR,与 OpenCV 兼容。
|
|
266
|
+
Used to pass image data between Python and C API. Image format is BGR, compatible with OpenCV.
|
|
267
|
+
"""
|
|
268
|
+
|
|
194
269
|
_handle: MaaImageBufferHandle
|
|
195
270
|
_own: bool
|
|
196
271
|
|
|
@@ -212,6 +287,11 @@ class ImageBuffer:
|
|
|
212
287
|
Library.framework().MaaImageBufferDestroy(self._handle)
|
|
213
288
|
|
|
214
289
|
def get(self) -> numpy.ndarray:
|
|
290
|
+
"""获取图像数据 / Get image data
|
|
291
|
+
|
|
292
|
+
Returns:
|
|
293
|
+
numpy.ndarray: BGR 格式图像,形状为 (height, width, channels) / BGR format image with shape (height, width, channels)
|
|
294
|
+
"""
|
|
215
295
|
buff = Library.framework().MaaImageBufferGetRawData(self._handle)
|
|
216
296
|
if not buff:
|
|
217
297
|
return numpy.ndarray((0, 0, 3), dtype=numpy.uint8)
|
|
@@ -226,9 +306,24 @@ class ImageBuffer:
|
|
|
226
306
|
)
|
|
227
307
|
|
|
228
308
|
def set(self, value: numpy.ndarray) -> bool:
|
|
309
|
+
"""设置图像数据 / Set image data
|
|
310
|
+
|
|
311
|
+
Args:
|
|
312
|
+
value: BGR 格式图像,形状为 (height, width, channels) / BGR format image with shape (height, width, channels)
|
|
313
|
+
|
|
314
|
+
Returns:
|
|
315
|
+
bool: 是否成功 / Whether successful
|
|
316
|
+
|
|
317
|
+
Raises:
|
|
318
|
+
TypeError: 如果 value 不是 numpy.ndarray
|
|
319
|
+
"""
|
|
229
320
|
if not isinstance(value, numpy.ndarray):
|
|
230
321
|
raise TypeError("value must be a numpy.ndarray")
|
|
231
322
|
|
|
323
|
+
# 确保数组是 C-contiguous 的,避免切片视图导致的内存不连续问题
|
|
324
|
+
if not value.flags['C_CONTIGUOUS']:
|
|
325
|
+
value = numpy.ascontiguousarray(value)
|
|
326
|
+
|
|
232
327
|
return bool(
|
|
233
328
|
Library.framework().MaaImageBufferSetRawData(
|
|
234
329
|
self._handle,
|
|
@@ -241,9 +336,19 @@ class ImageBuffer:
|
|
|
241
336
|
|
|
242
337
|
@property
|
|
243
338
|
def empty(self) -> bool:
|
|
339
|
+
"""判断缓冲区是否为空 / Check if buffer is empty
|
|
340
|
+
|
|
341
|
+
Returns:
|
|
342
|
+
bool: 是否为空 / Whether empty
|
|
343
|
+
"""
|
|
244
344
|
return bool(Library.framework().MaaImageBufferIsEmpty(self._handle))
|
|
245
345
|
|
|
246
346
|
def clear(self) -> bool:
|
|
347
|
+
"""清空缓冲区 / Clear buffer
|
|
348
|
+
|
|
349
|
+
Returns:
|
|
350
|
+
bool: 是否成功 / Whether successful
|
|
351
|
+
"""
|
|
247
352
|
return bool(Library.framework().MaaImageBufferClear(self._handle))
|
|
248
353
|
|
|
249
354
|
_api_properties_initialized: bool = False
|
|
@@ -292,6 +397,12 @@ class ImageBuffer:
|
|
|
292
397
|
|
|
293
398
|
|
|
294
399
|
class ImageListBuffer:
|
|
400
|
+
"""图像列表缓冲区 / Image list buffer
|
|
401
|
+
|
|
402
|
+
用于在 Python 和 C API 之间传递图像列表数据。
|
|
403
|
+
Used to pass image list data between Python and C API.
|
|
404
|
+
"""
|
|
405
|
+
|
|
295
406
|
_handle: MaaImageListBufferHandle
|
|
296
407
|
_own: bool
|
|
297
408
|
|
|
@@ -313,6 +424,11 @@ class ImageListBuffer:
|
|
|
313
424
|
Library.framework().MaaImageListBufferDestroy(self._handle)
|
|
314
425
|
|
|
315
426
|
def get(self) -> List[numpy.ndarray]:
|
|
427
|
+
"""获取图像列表 / Get image list
|
|
428
|
+
|
|
429
|
+
Returns:
|
|
430
|
+
List[numpy.ndarray]: 图像列表 / Image list
|
|
431
|
+
"""
|
|
316
432
|
count = Library.framework().MaaImageListBufferSize(self._handle)
|
|
317
433
|
result = []
|
|
318
434
|
for i in range(count):
|
|
@@ -322,6 +438,14 @@ class ImageListBuffer:
|
|
|
322
438
|
return result
|
|
323
439
|
|
|
324
440
|
def set(self, value: List[numpy.ndarray]) -> bool:
|
|
441
|
+
"""设置图像列表 / Set image list
|
|
442
|
+
|
|
443
|
+
Args:
|
|
444
|
+
value: 图像列表 / Image list
|
|
445
|
+
|
|
446
|
+
Returns:
|
|
447
|
+
bool: 是否成功 / Whether successful
|
|
448
|
+
"""
|
|
325
449
|
self.clear()
|
|
326
450
|
for img in value:
|
|
327
451
|
if not self.append(img):
|
|
@@ -329,6 +453,14 @@ class ImageListBuffer:
|
|
|
329
453
|
return True
|
|
330
454
|
|
|
331
455
|
def append(self, value: numpy.ndarray) -> bool:
|
|
456
|
+
"""追加图像 / Append image
|
|
457
|
+
|
|
458
|
+
Args:
|
|
459
|
+
value: 要追加的图像 / Image to append
|
|
460
|
+
|
|
461
|
+
Returns:
|
|
462
|
+
bool: 是否成功 / Whether successful
|
|
463
|
+
"""
|
|
332
464
|
buff = ImageBuffer()
|
|
333
465
|
buff.set(value)
|
|
334
466
|
return bool(
|
|
@@ -336,9 +468,22 @@ class ImageListBuffer:
|
|
|
336
468
|
)
|
|
337
469
|
|
|
338
470
|
def remove(self, index: int) -> bool:
|
|
471
|
+
"""移除指定索引的图像 / Remove image at index
|
|
472
|
+
|
|
473
|
+
Args:
|
|
474
|
+
index: 要移除的索引 / Index to remove
|
|
475
|
+
|
|
476
|
+
Returns:
|
|
477
|
+
bool: 是否成功 / Whether successful
|
|
478
|
+
"""
|
|
339
479
|
return bool(Library.framework().MaaImageListBufferRemove(self._handle, index))
|
|
340
480
|
|
|
341
481
|
def clear(self) -> bool:
|
|
482
|
+
"""清空列表 / Clear list
|
|
483
|
+
|
|
484
|
+
Returns:
|
|
485
|
+
bool: 是否成功 / Whether successful
|
|
486
|
+
"""
|
|
342
487
|
return bool(Library.framework().MaaImageListBufferClear(self._handle))
|
|
343
488
|
|
|
344
489
|
_api_properties_initialized: bool = False
|
|
@@ -390,6 +535,12 @@ class ImageListBuffer:
|
|
|
390
535
|
|
|
391
536
|
|
|
392
537
|
class RectBuffer:
|
|
538
|
+
"""矩形缓冲区 / Rectangle buffer
|
|
539
|
+
|
|
540
|
+
用于在 Python 和 C API 之间传递矩形数据(x, y, width, height)。
|
|
541
|
+
Used to pass rectangle data (x, y, width, height) between Python and C API.
|
|
542
|
+
"""
|
|
543
|
+
|
|
393
544
|
_handle: MaaRectHandle
|
|
394
545
|
_own: bool
|
|
395
546
|
|
|
@@ -411,6 +562,11 @@ class RectBuffer:
|
|
|
411
562
|
Library.framework().MaaRectDestroy(self._handle)
|
|
412
563
|
|
|
413
564
|
def get(self) -> Rect:
|
|
565
|
+
"""获取矩形数据 / Get rectangle data
|
|
566
|
+
|
|
567
|
+
Returns:
|
|
568
|
+
Rect: 矩形对象 (x, y, width, height) / Rectangle object (x, y, width, height)
|
|
569
|
+
"""
|
|
414
570
|
x = Library.framework().MaaRectGetX(self._handle)
|
|
415
571
|
y = Library.framework().MaaRectGetY(self._handle)
|
|
416
572
|
w = Library.framework().MaaRectGetW(self._handle)
|
|
@@ -419,6 +575,18 @@ class RectBuffer:
|
|
|
419
575
|
return Rect(x, y, w, h)
|
|
420
576
|
|
|
421
577
|
def set(self, value: RectType) -> bool:
|
|
578
|
+
"""设置矩形数据 / Set rectangle data
|
|
579
|
+
|
|
580
|
+
Args:
|
|
581
|
+
value: 矩形数据,可以是 Rect、tuple、list 或 numpy.ndarray / Rectangle data, can be Rect, tuple, list, or numpy.ndarray
|
|
582
|
+
|
|
583
|
+
Returns:
|
|
584
|
+
bool: 是否成功 / Whether successful
|
|
585
|
+
|
|
586
|
+
Raises:
|
|
587
|
+
ValueError: 如果数据格式不正确
|
|
588
|
+
TypeError: 如果类型不支持
|
|
589
|
+
"""
|
|
422
590
|
if isinstance(value, numpy.ndarray):
|
|
423
591
|
if value.ndim != 1:
|
|
424
592
|
raise ValueError("value must be a 1D array")
|