Skip to main content

Python library for automating Windows

Project description

autoxkit

PyPI version Python Version License

一个轻量级的 Windows 自动化库,支持鼠标与键盘操作模拟、全局hook监听、图色识别等功能。适用于自动化脚本、软件测试、人机交互等多种场景。


✨ 功能特色

  • ✅ 支持全局图色识别
  • ✅ 全局鼠标和键盘hook监听
  • ✅ 支持鼠标点击、移动、滚轮等操作
  • ✅ 支持按键按下、释放、文本输入等模拟
  • ✅ 简洁的事件回调机制,便于集成和扩展
  • ✅ 完全基于 Python 实现,易于上手和二次开发

📦 安装方式

从 PyPI 安装:

pip install autoxkit

或下载源码后本地安装:

pip install .

🔧 使用示例

"""
return False 只监听事件,不阻止事件传播
return True 监听事件,并阻止事件传播,可以理解为下一个窗口不会收到该事件
"""

import time
from autoxkit.mousekey 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


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.start()

if __name__ == '__main__':
    print("当前鼠标位置:", hook_listener.get_mouse_position())
    print("HookListener 正在运行... 按 Ctrl+C 退出")

    try:
        while True:
            time.sleep(1)
    except Exception:
        hook_listener.stop()

更多示例请参考:examples


📁 GitHub 项目地址

👉 https://github.com/YorickFin/autoxkit


📃 License

本项目基于 GPL-3.0 许可证开源,欢迎使用与二次开发。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autoxkit-0.4.5.tar.gz (27.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

autoxkit-0.4.5-py3-none-any.whl (29.3 kB view details)

Uploaded Python 3

File details

Details for the file autoxkit-0.4.5.tar.gz.

File metadata

  • Download URL: autoxkit-0.4.5.tar.gz
  • Upload date:
  • Size: 27.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.18

File hashes

Hashes for autoxkit-0.4.5.tar.gz
Algorithm Hash digest
SHA256 54e414a65f808d643ba5d3afe93d013a8f975d112b0b75583ff89ca4ff21c0c6
MD5 8cb15dee69bd94ddebfb937c0904e2f3
BLAKE2b-256 e3073bce7487da46ac02eb82bb932173dd74c72135f4aeb940d11e92a99aac86

See more details on using hashes here.

File details

Details for the file autoxkit-0.4.5-py3-none-any.whl.

File metadata

  • Download URL: autoxkit-0.4.5-py3-none-any.whl
  • Upload date:
  • Size: 29.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.18

File hashes

Hashes for autoxkit-0.4.5-py3-none-any.whl
Algorithm Hash digest
SHA256 80752e8f5d582fa96651260383bf105edbbbb5fc215ab403bb11283b2a3f6a43
MD5 2d8d5bbc1ef9637e8b55d3b62652de18
BLAKE2b-256 7c2badb6e3db8c693642fbf70cbf677ad095ed812bea0d3c13817f49574114bd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page