AutoMonkey 0.4.1__py3-none-any.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.
- automonkey/__init__.py +37 -0
- automonkey/ai/__init__.py +54 -0
- automonkey/ai/__main__.py +76 -0
- automonkey/ai/mcp_launch.py +62 -0
- automonkey/ai/mcp_server.py +114 -0
- automonkey/ai/ocr.py +149 -0
- automonkey/ai/screen.py +202 -0
- automonkey/ai/script.py +190 -0
- automonkey/ai/windows.py +185 -0
- automonkey/app_funcs.py +201 -0
- automonkey/atspi_funcs.py +1093 -0
- automonkey/automonkey.py +300 -0
- automonkey/constants.py +120 -0
- automonkey/exceptions.py +16 -0
- automonkey/img_funcs.py +301 -0
- automonkey/key_funcs.py +279 -0
- automonkey/mouse_funcs.py +37 -0
- automonkey/mouse_tracker.py +133 -0
- automonkey/pywinauto_funcs.py +343 -0
- automonkey/utils.py +169 -0
- automonkey-0.4.1.dist-info/METADATA +517 -0
- automonkey-0.4.1.dist-info/RECORD +27 -0
- automonkey-0.4.1.dist-info/WHEEL +5 -0
- automonkey-0.4.1.dist-info/entry_points.txt +3 -0
- automonkey-0.4.1.dist-info/licenses/AUTHORS.rst +13 -0
- automonkey-0.4.1.dist-info/licenses/LICENSE +33 -0
- automonkey-0.4.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: AutoMonkey
|
|
3
|
+
Version: 0.4.1
|
|
4
|
+
Summary: Python Automation using Mouse and Keyboard, for the masses
|
|
5
|
+
Author-email: Mihail-Cosmin Munteanu <munteanumihailcosmin@gmail.com>
|
|
6
|
+
License: GNU General Public License v3 (GPLv3)
|
|
7
|
+
Project-URL: Homepage, https://github.com/MihailCosmin/AutoMonkey
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/MihailCosmin/AutoMonkey/issues
|
|
9
|
+
Keywords: automonkey
|
|
10
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
13
|
+
Classifier: Natural Language :: English
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
21
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
22
|
+
Requires-Python: >=3.8
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
License-File: AUTHORS.rst
|
|
26
|
+
Requires-Dist: pyautogui>=0.9.54
|
|
27
|
+
Requires-Dist: pytesseract>=0.3.9
|
|
28
|
+
Requires-Dist: numpy
|
|
29
|
+
Requires-Dist: keyboard>=0.13.5
|
|
30
|
+
Requires-Dist: clipboard>=0.0.4
|
|
31
|
+
Requires-Dist: opencv-python
|
|
32
|
+
Requires-Dist: pillow>=9.5.0
|
|
33
|
+
Requires-Dist: screeninfo>=0.8
|
|
34
|
+
Requires-Dist: pyperclip==1.8.2
|
|
35
|
+
Requires-Dist: PyScreeze>=0.1.27
|
|
36
|
+
Requires-Dist: pywin32>=303; sys_platform == "win32"
|
|
37
|
+
Requires-Dist: pywin32-ctypes>=0.2.0; sys_platform == "win32"
|
|
38
|
+
Requires-Dist: pywinauto>=0.6.8; sys_platform == "win32"
|
|
39
|
+
Provides-Extra: ai
|
|
40
|
+
Requires-Dist: mcp>=2.0; extra == "ai"
|
|
41
|
+
Dynamic: license-file
|
|
42
|
+
|
|
43
|
+
[](https://www.paypal.com/donate/?hosted_button_id=5Q6TUMXS2QJW4)
|
|
44
|
+
[](https://snyk.io/test/github/MihailCosmin/AutoMonkey)
|
|
45
|
+
[](http://hits.dwyl.com/MihailCosmin/AutoMonkey)
|
|
46
|
+
[](https://github.com/MihailCosmin/AutoMonkey/actions/workflows/python-package.yml)
|
|
47
|
+
[](https://codeclimate.com/github/MihailCosmin/AutoMonkey)
|
|
48
|
+
|
|
49
|
+
# AutoMonkey
|
|
50
|
+
<img alt="AutoMonkey" src="https://github.com/MihailCosmin/AutoMonkey/raw/06181954fa23605583d61843226f5f3997157435/img/monkey.ico" width="100px" height="100px"/>
|
|
51
|
+
|
|
52
|
+
Python Automation using Mouse and Keyboard, for the masses
|
|
53
|
+
|
|
54
|
+
# Installation
|
|
55
|
+
|
|
56
|
+
1. From <a href="https://pypi.org/project/AutoMonkey/">pypi</a>:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
pip install AutoMonkey
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
2. From <a href="https://github.com/MihailCosmin/AutoMonkey">github</a>:
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
pip install git+https://github.com/MihailCosmin/AutoMonkey
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
# Dependencies
|
|
69
|
+
#### Automonkey is based on:
|
|
70
|
+
- <a href="https://github.com/asweigart/pyautogui">pyautogui</a>
|
|
71
|
+
|
|
72
|
+
#### Other dependencies:
|
|
73
|
+
- PyScreeze
|
|
74
|
+
- pyperclip
|
|
75
|
+
- clipboard
|
|
76
|
+
- keyboard
|
|
77
|
+
- screeninfo
|
|
78
|
+
- pywin32
|
|
79
|
+
- pillow
|
|
80
|
+
- opencv-python
|
|
81
|
+
- numpy
|
|
82
|
+
- pytesseract
|
|
83
|
+
- <a href="https://github.com/pywinauto/pywinauto">pywinauto</a> (Windows only, for the control actions)
|
|
84
|
+
|
|
85
|
+
# Usage
|
|
86
|
+
Main function to be used is "chain"
|
|
87
|
+
|
|
88
|
+
This will allow you to "chain" together most of the other functions of automonkey.
|
|
89
|
+
Which in turn will enable you to create sequences of mouse and/or keyboard actions in order to automate any given task.
|
|
90
|
+
|
|
91
|
+
A step can have this structure:
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
|
|
95
|
+
dict(
|
|
96
|
+
<action> = <target>, # action can be any of the automonkey functions, target on which the action will be performed
|
|
97
|
+
wait = 1, # wait is an optional parameter, which will wait for the given amount of seconds before executing the next step
|
|
98
|
+
skip = False, # if True, will skip this step
|
|
99
|
+
confidence = 0.9, # confidence is an optional parameter, Used only for actions on images. Confidence on locating the image.
|
|
100
|
+
v_offset = 0, # v_offset is an optional parameter, Used only for actions on images. Vertical offset from the center of the image.
|
|
101
|
+
h_offset = 0, # h_offset is an optional parameter, Used only for actions on images. Horizontal offset from the center of the image.
|
|
102
|
+
offset = 0, # offset is an optional parameter, Used only for actions on images. Offset from the center of the image.
|
|
103
|
+
monitor = 0, # monitor is an optional parameter, Used only for actions on images. Monitor on which to search for the image.
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
or
|
|
107
|
+
|
|
108
|
+
{
|
|
109
|
+
"<action>": "<target>", # action can be any of the automonkey functions, target on which the action will be performed
|
|
110
|
+
"wait": 1, # wait is an optional parameter, which will wait for the given amount of seconds before executing the next step
|
|
111
|
+
"skip": False, # if True, will skip this step
|
|
112
|
+
"confidence": 0.9, # confidence is an optional parameter, Used only for actions on images. Confidence on locating the image.
|
|
113
|
+
"v_offset": 0, # v_offset is an optional parameter, Used only for actions on images. Vertical offset from the center of the image.
|
|
114
|
+
"h_offset": 0, # h_offset is an optional parameter, Used only for actions on images. Horizontal offset from the center of the image.
|
|
115
|
+
"offset": 0, # offset is an optional parameter, Used only for actions on images. Offset from the center of the image.
|
|
116
|
+
"monitor": 0, # monitor is an optional parameter, Used only for actions on images. Monitor on which to search for the image.
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
1. You can connect multiple mouse actions together by using the "chain" function. Just by doing this you can generally automate most of the tasks you would do on a daily basis.
|
|
121
|
+
|
|
122
|
+
There are 2 main ways to click, either by giving the coordinates of the position where to click or by giving the filename of the image you want to click on
|
|
123
|
+
|
|
124
|
+
1.1. Clicking by coordinates
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
1.1.1. In order to find the coordinates of a position on the screen you can use the "track_mouse" function or the PositionTracker class
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from automonkey import track_mouse
|
|
131
|
+
track_mouse()
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
<img alt="track_mouse" src="https://github.com/MihailCosmin/AutoMonkey/raw/1fa19ba4517875d00c08cf320e628669d60714dc/demo/track_mouse.gif" width="416px" height="304px"/>
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
from automonkey import PositionTracker
|
|
139
|
+
tracker = PositionTracker()
|
|
140
|
+
tracker.start()
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
<img alt="PositionTracker" src="https://github.com/MihailCosmin/AutoMonkey/raw/1fa19ba4517875d00c08cf320e628669d60714dc/demo/PositionTracker.gif" width="918px" height="574px"/>
|
|
144
|
+
|
|
145
|
+
1.2.1. Now that you have the coordinates of the position you want to click on, you can use the "chain" function to click on it
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
from automonkey import chain
|
|
150
|
+
chain(
|
|
151
|
+
dict(click=(780, 1175), wait=1),
|
|
152
|
+
dict(click=(444, 194), wait=1),
|
|
153
|
+
dict(click=(1892, 110), wait=1),
|
|
154
|
+
debug=True
|
|
155
|
+
)
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
<img alt="click" src="https://github.com/MihailCosmin/AutoMonkey/raw/1fa19ba4517875d00c08cf320e628669d60714dc/demo/click.gif" width="960px" height="576px"/>
|
|
159
|
+
|
|
160
|
+
1.2. Clicking by image
|
|
161
|
+
|
|
162
|
+
1.2.1. To click on an image you first need to make a screenshot of the area you want to click on and save it somewhere on your computer.
|
|
163
|
+
For this you can use any screenshot tool you want, or you could use monkeyshot: https://github.com/MihailCosmin/monkeyshot
|
|
164
|
+
For example you can make a screenshot of the Edge icon from your toolbar, then we can click on it by using the "chain" function.
|
|
165
|
+
|
|
166
|
+
<img alt="edge_toolbar" src="https://github.com/MihailCosmin/AutoMonkey/raw/25eaed263793bf548d42f616e241f435baa9d719/demo/edge_toolbar.jpg" width="33px" height="33px"/>
|
|
167
|
+
|
|
168
|
+
1.2.2. Now that we have the image we want to click on, we can use the "chain" function to click on it
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
chain(
|
|
172
|
+
dict(click="demo/edge_toolbar.jpg"),
|
|
173
|
+
dict(click="demo/google_create_account", wait=1),
|
|
174
|
+
dict(click="demo/personal_use", wait=1),
|
|
175
|
+
debug=True
|
|
176
|
+
)
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
<img alt="click_image" src="https://github.com/MihailCosmin/AutoMonkey/raw/1fa19ba4517875d00c08cf320e628669d60714dc/demo/click_image.gif" width="918px" height="600px"/>
|
|
180
|
+
|
|
181
|
+
1.3. All mouse actions:
|
|
182
|
+
|
|
183
|
+
* click
|
|
184
|
+
* rightclick
|
|
185
|
+
* leftclick
|
|
186
|
+
* doubleclick
|
|
187
|
+
* tripleclick
|
|
188
|
+
* scrollup
|
|
189
|
+
* scrolldown
|
|
190
|
+
* scrollleft
|
|
191
|
+
* scrollright
|
|
192
|
+
|
|
193
|
+
2. You can also connect multiple keyboard actions together by using the "chain" function.
|
|
194
|
+
|
|
195
|
+
2.1. Write text - This doesn't work well with non-english character. For this you can use the "pastetext" function.
|
|
196
|
+
|
|
197
|
+
```python
|
|
198
|
+
chain(
|
|
199
|
+
dict(click="demo/notepad.jpg"),
|
|
200
|
+
dict(write="Hello World!"),
|
|
201
|
+
debug=True
|
|
202
|
+
)
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
<img alt="write" src="https://github.com/MihailCosmin/AutoMonkey/raw/1fa19ba4517875d00c08cf320e628669d60714dc/demo/write.gif" width="918px" height="600px"/>
|
|
206
|
+
|
|
207
|
+
2.2. Paste text - This works well with non-english characters
|
|
208
|
+
|
|
209
|
+
```python
|
|
210
|
+
chain(
|
|
211
|
+
dict(click="demo/notepad.jpg"),
|
|
212
|
+
dict(pastetext="Straße"),
|
|
213
|
+
debug=True
|
|
214
|
+
)
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
2.3. Key combinations
|
|
218
|
+
|
|
219
|
+
```python
|
|
220
|
+
chain(
|
|
221
|
+
dict(click="demo/notepad.jpg", wait=1),
|
|
222
|
+
dict(write="Hello World!", wait=1),
|
|
223
|
+
dict(keys2="ctrl+a", wait=1),
|
|
224
|
+
dict(keys2="ctrl+x", wait=1),
|
|
225
|
+
dict(keys2="alt+f4", wait=1), # close notepad
|
|
226
|
+
debug=True
|
|
227
|
+
)
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
<img alt="keys" src="https://github.com/MihailCosmin/AutoMonkey/raw/1fa19ba4517875d00c08cf320e628669d60714dc/demo/keys.gif" width="918px" height="600px"/>
|
|
231
|
+
|
|
232
|
+
2.4. All key actions:
|
|
233
|
+
|
|
234
|
+
* write
|
|
235
|
+
* pastetext
|
|
236
|
+
* keys
|
|
237
|
+
* keys2 - best option overall for key combinations
|
|
238
|
+
* keys3
|
|
239
|
+
* keys4
|
|
240
|
+
* copy
|
|
241
|
+
* paste
|
|
242
|
+
|
|
243
|
+
3. Wait actions:
|
|
244
|
+
|
|
245
|
+
3.1. Wait until an image appears on the screen
|
|
246
|
+
This can used when you are waiting for a window to finish loading completely and you don't know exactly how long that would take.
|
|
247
|
+
|
|
248
|
+
```python
|
|
249
|
+
chain(
|
|
250
|
+
dict(click="demo/notepad.jpg"),
|
|
251
|
+
dict(waituntil="demo/notepad_opened.jpg", wait=1),
|
|
252
|
+
dict(write="Hello World!", wait=1),
|
|
253
|
+
debug=True
|
|
254
|
+
)
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
3.2. Wait while an image is on the screen
|
|
258
|
+
|
|
259
|
+
4. App (window) actions:
|
|
260
|
+
|
|
261
|
+
4.1. Open an app
|
|
262
|
+
|
|
263
|
+
```python
|
|
264
|
+
chain(
|
|
265
|
+
dict(open_app="notepad++.exe", wait=1),
|
|
266
|
+
dict(waituntil="demo/notepad_opened.jpg", wait=1),
|
|
267
|
+
dict(write="Hello World!", wait=1),
|
|
268
|
+
debug=True
|
|
269
|
+
)
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
4.2. Close an app
|
|
273
|
+
|
|
274
|
+
```python
|
|
275
|
+
chain(
|
|
276
|
+
dict(open_app="notepad++.exe", wait=1),
|
|
277
|
+
dict(write="Hello World!", wait=1),
|
|
278
|
+
dict(close="Notepad", wait=1),
|
|
279
|
+
debug=True
|
|
280
|
+
)
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
4.3. Minimize an app
|
|
284
|
+
|
|
285
|
+
```python
|
|
286
|
+
chain(
|
|
287
|
+
dict(open_app="notepad++.exe", wait=1),
|
|
288
|
+
dict(write="Hello World!", wait=1),
|
|
289
|
+
dict(minimize="Notepad", wait=1),
|
|
290
|
+
debug=True
|
|
291
|
+
)
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
4.4. Maximize an app
|
|
295
|
+
|
|
296
|
+
```python
|
|
297
|
+
chain(
|
|
298
|
+
dict(open_app="notepad++.exe", wait=1),
|
|
299
|
+
dict(write="Hello World!", wait=1),
|
|
300
|
+
dict(maximize="Notepad", wait=1),
|
|
301
|
+
debug=True
|
|
302
|
+
)
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
4.5. Restore an app
|
|
306
|
+
|
|
307
|
+
```python
|
|
308
|
+
chain(
|
|
309
|
+
dict(open_app="notepad++.exe", wait=1),
|
|
310
|
+
dict(write="Hello World!", wait=1),
|
|
311
|
+
dict(minimize="Notepad", wait=1),
|
|
312
|
+
dict(restore="Notepad", wait=1),
|
|
313
|
+
debug=True
|
|
314
|
+
)
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
4.6. All app actions:
|
|
318
|
+
|
|
319
|
+
* open_app
|
|
320
|
+
* close
|
|
321
|
+
* startfile
|
|
322
|
+
* focus
|
|
323
|
+
* minimize
|
|
324
|
+
* maximize
|
|
325
|
+
* restore
|
|
326
|
+
* msoffice_replace
|
|
327
|
+
* copy_from
|
|
328
|
+
* copy_from_to
|
|
329
|
+
|
|
330
|
+
5. Image actions
|
|
331
|
+
|
|
332
|
+
5.1 count_img. With this function you can count how many times one image appears on the screen.
|
|
333
|
+
|
|
334
|
+
```python
|
|
335
|
+
chain(
|
|
336
|
+
dict(count_img="demo/M.jpg", wait=1), # The result will be copied to the clipboard
|
|
337
|
+
dict(open_app="notepad++.exe", wait=1),
|
|
338
|
+
dict(paste="", wait=1), # with paste we can paste the text from the clipboard
|
|
339
|
+
debug=True
|
|
340
|
+
)
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
5.2. get_text_from_region
|
|
344
|
+
|
|
345
|
+
```python
|
|
346
|
+
chain(
|
|
347
|
+
dict(get_text_from_region=((136, 121), (189, 140)), wait=1), # The text will be copied to the clipboard
|
|
348
|
+
dict(open_app="notepad++.exe", wait=1),
|
|
349
|
+
dict(paste="", wait=1), # with paste we can paste the text from the clipboard
|
|
350
|
+
debug=True
|
|
351
|
+
)
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
6. Control actions (Windows: <a href="https://github.com/pywinauto/pywinauto">pywinauto</a>; Linux: AT-SPI; macOS: not implemented yet)
|
|
355
|
+
|
|
356
|
+
These find buttons, text boxes and menus through the OS accessibility tree instead of
|
|
357
|
+
coordinates or images, so they keep working when the resolution, theme or window position changes.
|
|
358
|
+
Same function names and arguments on both OSes - a `chain` script using them needs no changes
|
|
359
|
+
to run on either one; only the `backend` argument's value differs (`"uia"`/`"win32"` on Windows,
|
|
360
|
+
`"atspi"` on Linux).
|
|
361
|
+
|
|
362
|
+
Every function takes the window title (regex, matched anywhere in the title, like focus/close)
|
|
363
|
+
and a control:
|
|
364
|
+
* a "best match" name: `"Save"`, `"SaveButton"`, `"Edit"`
|
|
365
|
+
* or a dict of search criteria: `{"title": "Save", "control_type": "Button"}`, `{"auto_id": "num7Button"}`
|
|
366
|
+
|
|
367
|
+
6.1 Windows (pywinauto)
|
|
368
|
+
|
|
369
|
+
Optional for all: `backend="uia"` (default, modern apps) or `"win32"` (older apps), `timeout=10` seconds.
|
|
370
|
+
|
|
371
|
+
In chain the target is a tuple of arguments or a dict of keyword arguments:
|
|
372
|
+
|
|
373
|
+
```python
|
|
374
|
+
from automonkey import chain, list_controls
|
|
375
|
+
|
|
376
|
+
list_controls("Calculator") # prints the controls and the names you can use
|
|
377
|
+
|
|
378
|
+
chain(
|
|
379
|
+
dict(open_app="calc", wait=1),
|
|
380
|
+
dict(wait_control="Calculator"),
|
|
381
|
+
dict(click_control=("Calculator", {"auto_id": "num7Button"})),
|
|
382
|
+
dict(click_control=("Calculator", {"auto_id": "plusButton"})),
|
|
383
|
+
dict(click_control=("Calculator", {"auto_id": "num5Button"})),
|
|
384
|
+
dict(click_control=dict(window="Calculator", control={"auto_id": "equalButton"}, invoke=True)),
|
|
385
|
+
dict(get_control_text=("Calculator", {"auto_id": "CalculatorResults"})), # copied to the clipboard
|
|
386
|
+
)
|
|
387
|
+
|
|
388
|
+
chain(
|
|
389
|
+
dict(open_app="notepad", wait=1),
|
|
390
|
+
dict(type_in_control=dict(window=" - Notepad$", control={"control_type": "Document"}, text="Hello (world)!")),
|
|
391
|
+
dict(select_menu=(" - Notepad$", "Edit->Select all")),
|
|
392
|
+
)
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
Available functions:
|
|
396
|
+
* start_app - start an application with pywinauto
|
|
397
|
+
* click_control, double_click_control, right_click_control - `invoke=True` presses it without moving the mouse
|
|
398
|
+
* type_in_control - types the text as it is; `literal=False` for pywinauto key syntax (`{ENTER}`, `^a`);
|
|
399
|
+
`pause=0.05` if a slow app loses characters
|
|
400
|
+
* set_control_text, get_control_text
|
|
401
|
+
* select_menu - path separated by `->`, e.g. `"File->Save As..."`
|
|
402
|
+
* select_item - item of a combo box / list
|
|
403
|
+
* check_control, uncheck_control
|
|
404
|
+
* wait_control, control_exists
|
|
405
|
+
* list_controls
|
|
406
|
+
* get_window, get_control - return the pywinauto objects for anything else
|
|
407
|
+
|
|
408
|
+
6.2 Linux (AT-SPI)
|
|
409
|
+
|
|
410
|
+
Setup (distro packages, not pip - PyGObject needs system build dependencies pip can't
|
|
411
|
+
guarantee): on Debian/Ubuntu/Raspberry Pi OS,
|
|
412
|
+
|
|
413
|
+
```bash
|
|
414
|
+
sudo apt-get install python3-gi gir1.2-atspi-2.0 at-spi2-core
|
|
415
|
+
gsettings set org.gnome.desktop.interface toolkit-accessibility true
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
The `toolkit-accessibility` key only affects apps started *after* it's enabled -
|
|
419
|
+
restart anything already running. Apps must also not have `NO_AT_BRIDGE=1` set in
|
|
420
|
+
their environment, which silently disables AT-SPI registration.
|
|
421
|
+
|
|
422
|
+
Not every app exposes an accessibility tree: GTK, GNOME and LibreOffice apps and
|
|
423
|
+
Firefox work out of the box; Qt apps need `QT_LINUX_ACCESSIBILITY_ALWAYS_ON=1` in
|
|
424
|
+
their environment before they start; Chrome/Electron apps need the
|
|
425
|
+
`--force-renderer-accessibility` flag; self-drawn/custom-rendered UIs (games,
|
|
426
|
+
canvas-based apps) can't expose one at all.
|
|
427
|
+
|
|
428
|
+
`control_type` maps to an AT-SPI role, not quite the same names pywinauto uses on
|
|
429
|
+
Windows - confirmed against real GTK widgets, not just the spec (a push button's role
|
|
430
|
+
is `BUTTON`, not `PUSH_BUTTON`, for instance):
|
|
431
|
+
|
|
432
|
+
| control_type | AT-SPI role(s) |
|
|
433
|
+
| --- | --- |
|
|
434
|
+
| `Button` | `BUTTON`, `PUSH_BUTTON`, `TOGGLE_BUTTON` |
|
|
435
|
+
| `CheckBox` | `CHECK_BOX` |
|
|
436
|
+
| `RadioButton` | `RADIO_BUTTON` |
|
|
437
|
+
| `ComboBox` | `COMBO_BOX` |
|
|
438
|
+
| `Edit` | `TEXT`, `ENTRY`, `PASSWORD_TEXT` (also a plain GTK text editor's main area - see note below) |
|
|
439
|
+
| `Document` | `DOCUMENT_TEXT`, `DOCUMENT_FRAME`, `DOCUMENT_WEB`, ... (LibreOffice/WebKit-style content) |
|
|
440
|
+
| `Static` | `LABEL` |
|
|
441
|
+
| `MenuItem` | `MENU_ITEM`, `CHECK_MENU_ITEM`, `RADIO_MENU_ITEM`, `TEAROFF_MENU_ITEM` |
|
|
442
|
+
| `Menu` | `MENU`, `POPUP_MENU` |
|
|
443
|
+
| `MenuBar` | `MENU_BAR` |
|
|
444
|
+
| `List` | `LIST`, `LIST_BOX` |
|
|
445
|
+
| `ListItem` | `LIST_ITEM` |
|
|
446
|
+
| `Tab` / `TabControl` | `PAGE_TAB` / `PAGE_TAB_LIST` |
|
|
447
|
+
| `Window` / `Dialog` | `FRAME` / `DIALOG` |
|
|
448
|
+
|
|
449
|
+
`auto_id` matches the AT-SPI accessible-id or an `"id"` attribute if the app sets one
|
|
450
|
+
(most GTK apps don't), falling back to the accessible name otherwise.
|
|
451
|
+
|
|
452
|
+
Known Wayland limits: AT-SPI tree reading and actions (`invoke=True`, `check_control`,
|
|
453
|
+
`select_menu`, ...) work the same as on X11/Xwayland. What doesn't: mouse clicks
|
|
454
|
+
(`click_control(invoke=False)`) and keyboard injection (`type_in_control`) only reach
|
|
455
|
+
apps running under Xwayland - a native-Wayland client never receives them at all, no
|
|
456
|
+
matter what has focus (confirmed directly: the identical app forced through Xwayland
|
|
457
|
+
via `GDK_BACKEND=x11` works, the native-Wayland instance silently doesn't). Raising/
|
|
458
|
+
activating a window doesn't work either. `click_control(invoke=False)` detects a
|
|
459
|
+
Wayland session and falls back to `invoke=True` with a warning; `type_in_control` has
|
|
460
|
+
no such fallback - use `invoke=True`-based actions where possible, or run the target
|
|
461
|
+
app under Xwayland (`GDK_BACKEND=x11` for GTK apps) if it must be driven by mouse/
|
|
462
|
+
keyboard injection on Wayland.
|
|
463
|
+
|
|
464
|
+
```python
|
|
465
|
+
from automonkey import chain, list_controls
|
|
466
|
+
|
|
467
|
+
list_controls("Calculator") # prints the controls and the names you can use
|
|
468
|
+
|
|
469
|
+
chain(
|
|
470
|
+
# a short wait after each click matters here: Atspi.Action.do_action() returns
|
|
471
|
+
# once the D-Bus call completes, not once the app has processed the resulting
|
|
472
|
+
# GTK signal - clicking straight through with no pause silently drops presses
|
|
473
|
+
# (confirmed directly while building this).
|
|
474
|
+
dict(start_app="gnome-calculator", wait=1),
|
|
475
|
+
dict(wait_control="Calculator"),
|
|
476
|
+
dict(click_control=dict(window="Calculator", control={"title": "7", "control_type": "Button"}, invoke=True), wait=0.3),
|
|
477
|
+
dict(click_control=dict(window="Calculator", control={"title": "+", "control_type": "Button"}, invoke=True), wait=0.3),
|
|
478
|
+
dict(click_control=dict(window="Calculator", control={"title": "5", "control_type": "Button"}, invoke=True), wait=0.3),
|
|
479
|
+
dict(click_control=dict(window="Calculator", control={"title": "=", "control_type": "Button"}, invoke=True), wait=0.3),
|
|
480
|
+
dict(get_control_text=("Calculator", {"control_type": "Edit"})), # copied to the clipboard
|
|
481
|
+
)
|
|
482
|
+
|
|
483
|
+
chain(
|
|
484
|
+
# control_type "Edit" (AT-SPI role "text"), not "Document": gnome-text-editor's
|
|
485
|
+
# main area is a plain GtkSourceView widget, same as most GTK text editors -
|
|
486
|
+
# "Document*" roles are for LibreOffice/WebKit-style content, confirmed against
|
|
487
|
+
# a GtkSourceView-based app while building this.
|
|
488
|
+
dict(start_app="gnome-text-editor", wait=1),
|
|
489
|
+
dict(type_in_control=dict(window="Text Editor", control={"control_type": "Edit"}, text="Hello (world)!")),
|
|
490
|
+
dict(get_control_text=("Text Editor", {"control_type": "Edit"})), # copied to the clipboard
|
|
491
|
+
)
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
`select_menu` isn't shown against gnome-text-editor above: it's a modern GNOME app
|
|
495
|
+
with no traditional File/Edit menu bar at all (confirmed - zero AT-SPI menu-role nodes
|
|
496
|
+
anywhere in its tree), not an AT-SPI limitation. It works the same way as on Windows
|
|
497
|
+
against any app that does have one, e.g. `select_menu("Mousepad", "File->Save As...")`.
|
|
498
|
+
|
|
499
|
+
Same available functions as the Windows list above (`backend="atspi"`, the default on
|
|
500
|
+
Linux, instead of `"uia"`/`"win32"`); `get_window`/`get_control` return `Atspi.Accessible`
|
|
501
|
+
objects instead of pywinauto wrappers for anything not covered here.
|
|
502
|
+
|
|
503
|
+
See `pywinauto_for_linux.md` in the repo for the full implementation notes (role
|
|
504
|
+
mapping, best-match lookup, the AT-SPI-bus-down detection, known gotchas found while
|
|
505
|
+
building this) if you need to go beyond what's documented above.
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
# Frequently Asked Questions:
|
|
509
|
+
|
|
510
|
+
1. I made an image but it doesn't click on it.
|
|
511
|
+
|
|
512
|
+
A: Make sure you have not changed resolution of your screen or the theme (dark/light) of the window.
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
2. Keys combination using "keys" function doesn't work.
|
|
516
|
+
|
|
517
|
+
A: Try other keys functions. Preferably "keys2". Other options "keys3", "keys4".
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
automonkey/__init__.py,sha256=pUugjClgW5uNm_pdv-IHSwk0xAGOoJkR5_H3VsJZbXk,1603
|
|
2
|
+
automonkey/app_funcs.py,sha256=WJFNIsYWhN7P9xU0cKui-GeBf2JmYcm9PBLk3vhKS2E,5687
|
|
3
|
+
automonkey/atspi_funcs.py,sha256=7AZQv80eAcF59wt--Ar1_b6I7M-QQ7cYpCl4cHZLWj0,42690
|
|
4
|
+
automonkey/automonkey.py,sha256=rxgg3TrXCdEGArOOg1f-16rb4PrYuQZCydEEl9VL7wU,12043
|
|
5
|
+
automonkey/constants.py,sha256=zGDSV7F0Ww-1Km6jC6rsgUxPb0Gl2446PNheuymXIHw,2201
|
|
6
|
+
automonkey/exceptions.py,sha256=SfgRLz8HYWphcRluWRJ5FHqXx5ekvnimpRtBb6bMHrk,589
|
|
7
|
+
automonkey/img_funcs.py,sha256=Y6Lg_WVb9eU-TUOtRbVcrCC2RQW8pfB7Iwt4-xK0tHo,10013
|
|
8
|
+
automonkey/key_funcs.py,sha256=f8NfUO3-_dD0oZiDLTR14u197xNlkC9pjnksMF4l7S0,12966
|
|
9
|
+
automonkey/mouse_funcs.py,sha256=cqlN5ZMnWFkg4ic8k1M3UFfahJvtZcndZrVi_9V-3lc,1269
|
|
10
|
+
automonkey/mouse_tracker.py,sha256=UoLdctTAI7O6MSAnxRRXO0tJavYgmY_CUXU4r9dLUMU,4263
|
|
11
|
+
automonkey/pywinauto_funcs.py,sha256=Vi5A8pDFL-HAYl8y6o4IvFfxK2sXftxbvzGHZvyT30o,14003
|
|
12
|
+
automonkey/utils.py,sha256=7AQUcfZxEGjqasJVpy8ZBeUi3qxPq6t-mWJt92a9BtA,5067
|
|
13
|
+
automonkey/ai/__init__.py,sha256=qH32BtFKUc_W2EFLDey0ozRGKnSe-c3Aa7OAQQ0XLzk,1834
|
|
14
|
+
automonkey/ai/__main__.py,sha256=8QhQNqH38gppQxm6Zc4gbyLw_b2Br0Nye5vuEad5Bhk,3131
|
|
15
|
+
automonkey/ai/mcp_launch.py,sha256=NnKl8YLpi-yxEFN4U3o2IoBFH-F3s5PCgLnuSM1wHrY,2577
|
|
16
|
+
automonkey/ai/mcp_server.py,sha256=yceFZyMYzG7jpNrE9FTEWYzYNwbkGiPb40fgmb7op3E,4889
|
|
17
|
+
automonkey/ai/ocr.py,sha256=0K2x7RuZkJZvaWaoYwwpDhwbKhMNNg_h_2Jqg9wCyMM,6153
|
|
18
|
+
automonkey/ai/screen.py,sha256=k5Y52mBgHxpiP9XgKxLMzFxXjOyhAYT0KcqYUG9xDww,7933
|
|
19
|
+
automonkey/ai/script.py,sha256=S8KU1RIynOTB4Rp7phvEGysKGBxGgZAjSRdNFLA3AD4,7635
|
|
20
|
+
automonkey/ai/windows.py,sha256=53xxTsVrHwl0wAiZSQE4PtXxAAfBh3qLTVIhX-IhefY,7405
|
|
21
|
+
automonkey-0.4.1.dist-info/licenses/AUTHORS.rst,sha256=oNCDpSb6E-94ooSfuojd9vOx-Qh3ZtgWxfXAicnvVI8,178
|
|
22
|
+
automonkey-0.4.1.dist-info/licenses/LICENSE,sha256=UFfxrgz0tge2OHZHq4b6VDRGspdoLuFhPQuPVrHISAg,1582
|
|
23
|
+
automonkey-0.4.1.dist-info/METADATA,sha256=hldiUjzN370jcdiFFatUe-DzolsYXs3zlO5C1oGINgc,21586
|
|
24
|
+
automonkey-0.4.1.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
25
|
+
automonkey-0.4.1.dist-info/entry_points.txt,sha256=iWGJPn1teFR_ITo7pYMd6j4hH9cNHvgr9m3hL3ziEdk,109
|
|
26
|
+
automonkey-0.4.1.dist-info/top_level.txt,sha256=MFPSya0eblfAFkh-Pi_2KTZ_CadN246KOv9HC9-vy3M,11
|
|
27
|
+
automonkey-0.4.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
GNU GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Python Automation using Mouse and Keyboard for the masses
|
|
5
|
+
Copyright (C) 2021 Mihail-Cosmin Munteanu
|
|
6
|
+
|
|
7
|
+
This program is free software: you can redistribute it and/or modify
|
|
8
|
+
it under the terms of the GNU General Public License as published by
|
|
9
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
(at your option) any later version.
|
|
11
|
+
|
|
12
|
+
This program is distributed in the hope that it will be useful,
|
|
13
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
GNU General Public License for more details.
|
|
16
|
+
|
|
17
|
+
You should have received a copy of the GNU General Public License
|
|
18
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
19
|
+
|
|
20
|
+
Also add information on how to contact you by electronic and paper mail.
|
|
21
|
+
|
|
22
|
+
You should also get your employer (if you work as a programmer) or school,
|
|
23
|
+
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
|
24
|
+
For more information on this, and how to apply and follow the GNU GPL, see
|
|
25
|
+
<http://www.gnu.org/licenses/>.
|
|
26
|
+
|
|
27
|
+
The GNU General Public License does not permit incorporating your program
|
|
28
|
+
into proprietary programs. If your program is a subroutine library, you
|
|
29
|
+
may consider it more useful to permit linking proprietary applications with
|
|
30
|
+
the library. If this is what you want to do, use the GNU Lesser General
|
|
31
|
+
Public License instead of this License. But first, please read
|
|
32
|
+
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
|
33
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
automonkey
|