大漠插件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: 常见问题
注意事项
- 使用前需要安装大漠插件
- 需要有效的注册码和注册密钥
- 仅支持Windows系统
- Python版本要求 >= 3.7 32位
贡献
欢迎提交问题和拉取请求到 GitHub仓库。
作者
- patrickwu123
许可证
MIT License
Project details
Release history Release notifications | RSS feed
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)
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
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b1bbae2ffc978182f60b0a5237fc7940abf57585d38965d35c843fb3ae500b5
|
|
| MD5 |
2a2d1637dc2482fa55474693f9a73bec
|
|
| BLAKE2b-256 |
3644afeaecca201a9b2a28b0b7023e1e32d504f9c9ae517035706f617b5a15bd
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da99293c78c08f02953fb81bf98d96772c762f9d1291144995e7fca854be6e57
|
|
| MD5 |
83d0c04df7df6a37f7f24c8fa68f1d32
|
|
| BLAKE2b-256 |
d833d41ad3a241bee3e62287da4ef7c2bb31dafbf8bb5b550caa1504e1dd1781
|