autoxkit
一个轻量级的 python 自动化库,支持 Windows 前后台键鼠操作、图像识别、全局 hook 监听等,Android 模块基于 scrcpy-server v4.0 协议支持 Android 无线/有线投屏、键鼠映射等功能。 适用于自动化脚本、软件测试、人机交互等多种场景。
功能特色
- 前后台键鼠操作
- 前后台图像识别
- 文本输入模拟
- 全局键鼠 hook 监听
- Android 无线/有线投屏
- Android 键鼠映射
Android 模块依赖于 scrcpy v4.0 ,请自行前往 scrcpy v4.0 下载 scrcpy-win64-v4.0.zip 文件。
安装方式
从 PyPI 安装:
pip install autoxkit
或下载源码后本地安装:
pip install .
示例代码
"""
return Any or not return 只监听事件,不阻止事件传播
return True 监听事件,并阻止事件传播,可以理解为下一个窗口不会收到该事件
"""
from autoxkit.hook import HookListener, KeyEvent, MouseEvent
def key_down(event: KeyEvent):
print(event.action, event.key_code, event.key_name)
if event.key_name == 'A':
print("A键将被阻止传播,其他窗口将无法接收到该事件")
return True
return False
def key_up(event: KeyEvent):
print(event.action, event.key_code, event.key_name)
return False
def mouse_down(event: MouseEvent):
print(event.action, event.button, event.position)
return False
def mouse_up(event: MouseEvent):
print(event.action, event.button, event.position)
return False
def mouse_move(event: MouseEvent):
print(event.action, event.button, event.position)
return False
hook_listener = HookListener()
hook_listener.add_handler('keydown', key_down)
hook_listener.add_handler('keyup', key_up)
hook_listener.add_handler('mousedown', mouse_down)
hook_listener.add_handler('mouseup', mouse_up)
hook_listener.add_handler('mousemove', mouse_move)
hook_listener.start()
print("当前鼠标位置:", hook_listener.get_mouse_position())
if __name__ == '__main__':
try:
hook_listener.wait()
except Exception:
hook_listener.stop()
更多示例代码请参考 examples
GitHub 项目地址
https://github.com/YorickFin/autoxkit
License
本项目基于 GPL-3.0 许可开源,欢迎使用与二次开发。
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
autoxkit-2.4.4.tar.gz
(51.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
autoxkit-2.4.4-py3-none-any.whl
(60.3 kB
view details)
File details
Details for the file autoxkit-2.4.4.tar.gz.
File metadata
- Download URL: autoxkit-2.4.4.tar.gz
- Upload date:
- Size: 51.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24876463d2c6ba88d1fdb2cddf1bacfbb9f7f8d88fb52a3234de531205ef32d1
|
|
| MD5 |
784ac133787933b6158b2f8a5122845d
|
|
| BLAKE2b-256 |
9a8ce7105a660320f5dca292ca1f24b1c5eceb39a5b50c7b0060bb99bfb68a83
|
File details
Details for the file autoxkit-2.4.4-py3-none-any.whl.
File metadata
- Download URL: autoxkit-2.4.4-py3-none-any.whl
- Upload date:
- Size: 60.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04d73c802a680933ee463db373b06b25d63563d32ad3b451da713b552118cfd8
|
|
| MD5 |
e140cd9978baf2bb2f0780fea062d2c6
|
|
| BLAKE2b-256 |
516b494bf727c7eab3a8fe63641f291d81493ace76cd5f7c328d104a65d322c0
|