Skip to main content

基于大漠插件的Python自动化封装库

Project description

xtdamo

xtdamo 是一个基于大漠插件(Dm) 的封装库,用于自动化操作,包括窗口管理、鼠标控制、键盘模拟、图像识别、文本查找等功能。适用于游戏脚本、自动化测试等场景。

简介

xtdamo 提供了对大漠插件的高级封装,简化了与窗口、鼠标、键盘和图像识别相关的操作。主要功能包括:

  • 窗口绑定与管理
  • 鼠标移动与点击
  • 键盘按键模拟
  • 图像识别与查找
  • 文本识别与查找
  • 文件与注册表操作

安装

系统要求

  • Python 3.8+ (32 位版本) - 大漠插件仅支持 32 位 Python 环境
  • Windows 操作系统
  • 大漠插件(dm.dll)

重要提示: 大漠插件只能在 32 位 Python 环境下运行,请确保使用 32 位 Python 版本。

安装方法

  1. 创建 32 位 Python 虚拟环境
# 确保使用32位Python创建虚拟环境
python -m venv .venv --python=python3.12-32  # 或指定32位Python路径
.venv\Scripts\activate  # Windows
  1. 从源码安装
git clone https://github.com/sandorn/xtdamo.git
cd xtdamo
pip install -e .
  1. 从 PyPI 安装(计划中):
pip install xtdamo

注意: 请确保在 32 位 Python 环境中安装和运行项目。

大漠插件配置

将大漠插件(dm.dll)放置在项目目录中,或通过环境变量指定路径:

# 设置大漠插件认证信息(可选)
set DM_REG_CODE=your_registration_code
set DM_VER_INFO=your_version_info

使用示例

初始化大漠插件

from xtdamo import DmExcute

# 使用默认配置初始化
dm = DmExcute()

# 或指定大漠插件路径
dm = DmExcute(dm_dirpath="path_to_dm_dll")

基本操作

# 获取插件信息
print(f"版本: {dm.ver()}")
print(f"ID: {dm.GetID()}")

# 获取当前鼠标位置
x, y = dm.position
print(f"鼠标位置: ({x}, {y})")

# 移动鼠标
dm.move_to(100, 200)

# 安全点击
dm.safe_click(300, 400)

窗口操作

# 查找窗口
hwnd = dm.FindWindow("Notepad", "无标题 - 记事本")

# 绑定窗口
dm.BindWindow(hwnd, "gdi", "windows3", "windows", 101)

# 在窗口内查找图像
result = dm.FindPic(0, 0, 800, 600, "button.png")
if result[0] == 1:
    x, y = result[1], result[2]
    dm.safe_click(x, y)

鼠标操作

from xtdamo.mouse import Mouse

mouse = Mouse(dm)
mouse.move_to(100, 200)  # 移动鼠标到指定坐标
mouse.click_left(100, 200)  # 左键点击

键盘操作

from xtdamo.key import Key

key = Key(dm)
key.press("A")  # 按下 A 键
key.down("Enter")  # 按下 Enter 键
key.up("Enter")  # 释放 Enter 键

贡献

欢迎贡献代码或提出建议!请参考 贡献指南 获取更多信息。

许可证

本项目遵循 MIT 许可证

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

xtdamo-0.1.0.tar.gz (29.9 kB view details)

Uploaded Source

Built Distribution

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

xtdamo-0.1.0-py3-none-any.whl (32.1 kB view details)

Uploaded Python 3

File details

Details for the file xtdamo-0.1.0.tar.gz.

File metadata

  • Download URL: xtdamo-0.1.0.tar.gz
  • Upload date:
  • Size: 29.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for xtdamo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c2c286fe55c5186c80a88e09ab1730b283eb1c935d4cce50dfb2e75263077cfd
MD5 f5dc76f5c442779ebf9681f534351b92
BLAKE2b-256 369e9be88bb7e5db0f088a0acfc9f7ed6f37dd787f11f1bacbdc2475237406c3

See more details on using hashes here.

File details

Details for the file xtdamo-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: xtdamo-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 32.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for xtdamo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8eef38d82d743792e8e45546079e1b39c8f790a4c47ecc561f9943deab874491
MD5 2652c949eb61a2de10c3b838ab5e5ece
BLAKE2b-256 ab20d875000f72fa545c94efd865554913ddcc4e5832712aa4a681a552f4bfa9

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