Skip to main content

大漠插件Python封装

Project description

dmtopython

大漠插件Python封装,提供了简单易用的Python接口。 同时提供 TypeScript 类型定义,方便在 PyWebView 等环境中使用。 并且闲得蛋疼提供了中文函数名. 大漠插件需要32位python环境. 需要注册码和注册密钥.并且大漠插件已注册.

安装

pip install dmtopython

使用方法

有两种使用方式:

1. 使用完整功能(推荐)

from dmtopython import DmSoft

# 创建DM对象并注册
dm = DmSoft(code="注册码", key="注册密钥")


# 使用鼠标功能
dm.mouse.MoveTo(100, 100)
dm.mouse.LeftClick()

# 使用键盘功能
dm.keyboard.KeyPress(65)

# 查找和绑定窗口
hwnd = dm.window.FindWindow("记事本", "无标题")
if hwnd > 0:
    dm.window.BindWindow(hwnd, "normal", "normal", "normal", 0)

# 截图功能
dm.ai.Capture(0, 0, 100, 100, "screen.png")

# 文字识别
text = dm.ocr.Ocr(0, 0, 100, 100, "000000-000000", 0.9)

2. 单独使用某个功能

如果只需要某个特定功能,可以直接使用对应的类:

# 只使用鼠标功能
from dmtopython import DmMouse

mouse = DmMouse(code="注册码", key="注册密钥")
mouse.MoveTo(100, 100)
mouse.LeftClick()

# 只使用键盘功能
from dmtopython import DmKeyboard

keyboard = DmKeyboard(code="注册码", key="注册密钥")
keyboard.KeyPress(65)

# 只使用窗口操作
from dmtopython import DmWindow

window = DmWindow(code="注册码", key="注册密钥")
hwnd = window.FindWindow("记事本", "无标题")

TypeScript 支持

项目提供了完整的 TypeScript 类型定义文件,可以在 PyWebView 等环境中获得完整的类型提示:

// 复制 types/dmsoft.d.ts 到你的项目中

// 在 TypeScript 文件中使用
declare const dm: DmSoftType.DmSoft;

// 现在你可以获得完整的类型提示
dm.mouse.MoveTo(100, 100);
dm.keyboard.KeyPress(65);

// 在 PyWebView 中的使用示例
window.pywebview.api.dm.mouse.MoveTo(100, 100).then(() => {
    console.log('移动鼠标成功');
});

// 所有方法都有完整的参数和返回值类型定义
const hwnd = await window.pywebview.api.dm.window.FindWindow("记事本", "无标题");
if (hwnd > 0) {
    await window.pywebview.api.dm.window.BindWindow(hwnd, "normal", "normal", "normal", 0);
}

在 PyWebView 中使用

import webview
from dmtopython import DmSoft

class Api:
    def __init__(self):
        self.dm = DmSoft(code="注册码", key="注册密钥")
        if self.dm.create_dm() != 1:
            raise Exception("创建对象失败")

api = Api()
window = webview.create_window('DM示例', html='index.html', js_api=api)
webview.start()
<!-- index.html -->
<script>
// 确保 types/dmsoft.d.ts 在项目中
async function clickButton() {
    try {
        // 获得完整的类型提示
        await window.pywebview.api.dm.mouse.MoveTo(100, 100);
        await window.pywebview.api.dm.mouse.LeftClick();
    } catch (e) {
        console.error(e);
    }
}
</script>

功能模块

  • DmAi: 截图等AI相关功能
  • DmMouse: 鼠标操作
  • DmKeyboard: 键盘操作
  • DmWindow: 窗口操作
  • DmFoobar: Foobar控件操作
  • DmMemory: 内存操作
  • DmSystem: 系统操作
  • DmOcr: 文字识别
  • DmFile: 文件操作
  • DmFind: 图色查找
  • DmBg: 后台设置
  • DmAsm: 汇编操作
  • DmDmg: 图色设置
  • DmFaq: 常见问题

注意事项

  1. 使用前需要安装大漠插件
  2. 需要有效的注册码和注册密钥
  3. 仅支持Windows系统
  4. Python版本要求 >= 3.7 32位

贡献

欢迎提交问题和拉取请求到 GitHub仓库

作者

  • patrickwu123

许可证

MIT License

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

dmtopython-0.1.2.tar.gz (89.7 kB view details)

Uploaded Source

Built Distribution

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

dmtopython-0.1.2-py3-none-any.whl (66.8 kB view details)

Uploaded Python 3

File details

Details for the file dmtopython-0.1.2.tar.gz.

File metadata

  • Download URL: dmtopython-0.1.2.tar.gz
  • Upload date:
  • Size: 89.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for dmtopython-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4b1bbae2ffc978182f60b0a5237fc7940abf57585d38965d35c843fb3ae500b5
MD5 2a2d1637dc2482fa55474693f9a73bec
BLAKE2b-256 3644afeaecca201a9b2a28b0b7023e1e32d504f9c9ae517035706f617b5a15bd

See more details on using hashes here.

File details

Details for the file dmtopython-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: dmtopython-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 66.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for dmtopython-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 da99293c78c08f02953fb81bf98d96772c762f9d1291144995e7fca854be6e57
MD5 83d0c04df7df6a37f7f24c8fa68f1d32
BLAKE2b-256 d833d41ad3a241bee3e62287da4ef7c2bb31dafbf8bb5b550caa1504e1dd1781

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