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="注册密钥")
if dm.create_dm() != 1:
    print("创建对象失败")
    exit()

# 使用鼠标功能
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.1.tar.gz (89.8 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.1-py3-none-any.whl (66.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dmtopython-0.1.1.tar.gz
  • Upload date:
  • Size: 89.8 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.1.tar.gz
Algorithm Hash digest
SHA256 6f411cb8b1f63deeed36fd3a6654329b6042f73d2c48a365eaff5efb1bb1740c
MD5 58a175bf9380af9b82dbf56d76fa689f
BLAKE2b-256 1a6dab540618b8291c8694e390e8a76733f6c1f5e1e07438fd7fb9ef1e5b9fa6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dmtopython-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d09fd7fe92d9e344e5acf41105bef86cdc0ac5859d17711f82fa3f4f1a7abcdb
MD5 24bc452060af6f531edcc6904e5bc610
BLAKE2b-256 162c287deea2c44657a821a62c89f02a5fa222263f86fdf7c23c64fbbef962de

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