Skip to main content

Python bindings for OP Windows automation plugin

Project description

OP - Windows 自动化插件

GitHub Release CI License Platform

English

OP (Operator & Open) 是一个面向 Windows 的开源自动化插件,提供窗口操作、后台键鼠、截图、找色找图、OCR、OpenCV 图像处理、内存读写等能力。项目以 C++ 实现,提供 COM 接口,支持 x86/x64。

OCR 同时支持两条路径:固定字体场景可以使用本地点阵字库,兼容 OP 二进制字库和大漠文本点阵字库格式;不使用点阵字库时,可以接入独立 OCR HTTP 服务 op_ocr_engine,支持 Tesseract 和 PaddleOCR 等通用/模型 OCR 后端。

文档

主要能力

  • 窗口查询、窗口状态、窗口布局和后台绑定
  • 前台/后台鼠标键盘模拟
  • GDI、DXGI、WGC、DirectX、OpenGL 等截图方式
  • 找色、找图、图片输入源和内存图片输入
  • 点阵字库 OCR,兼容 OP 字库和大漠文本点阵字库格式
  • 独立 OCR HTTP 服务接入,支持 Tesseract、PaddleOCR 等通用/模型 OCR 后端
  • OpenCV 模板匹配、特征匹配和文件预处理
  • 进程内存读写、汇编调用和基础算法工具

目录概览

op/
├─ libop/          核心插件源码
│  ├─ com/         COM 注册、IDL、类型库和 IOpInterface 对外接口实现
│  ├─ background/  窗口绑定、截图输入源、后台显示/鼠标/键盘调度
│  ├─ imageProc/   找色、找图、点阵 OCR、OCR HTTP 服务封装
│  ├─ opencv/      OpenCV 模板匹配、特征匹配、预处理和桥接层
│  ├─ winapi/      窗口、进程、内存、注入等 Windows API 封装
│  ├─ core/        公共工具、路径、环境、管道、窗口布局等基础能力
│  ├─ include/     图像、颜色、字库、共享内存等内部基础结构
│  ├─ algorithm/   A* 等通用算法
│  ├─ libop.cpp    C++ 主接口实现,COM/SWIG 最终调用到这里
│  └─ libop.h      C++ 主接口声明
├─ include/        对外头文件和导出接口
├─ tools/          免注册加载工具源码,生成 tools.dll
├─ swig/           Python SWIG 绑定文件
├─ python/         pip wheel 包源码(python/pyop)
├─ examples/       本地测试示例和测试资源
├─ tests/          C++ 单元测试和集成测试
├─ doc/op.wiki/    GitHub Wiki 文档源码
├─ 3rd_party/      第三方源码或本地依赖
├─ ci/             CI 辅助脚本
├─ bin/            预置或构建后的运行文件
├─ out/            历史或可选输出目录
├─ build.py        推荐的一键构建入口
└─ CMakeLists.txt  CMake 工程入口

快速开始

下载 Release 后,根据宿主程序位数注册对应 DLL:

# 32 位宿主程序
regsvr32 op_x86.dll

# 64 位宿主程序
regsvr32 op_x64.dll

Python 最小示例(COM,与 Python 版本无关):

from win32com.client import Dispatch

op = Dispatch("op.opsoft")
print("op version:", op.Ver())

pip 安装(推荐 Python 用户使用)

op-plugins 通过 PyPI 发布多版本 wheel(Python 3.9–3.12,win32/win_amd64),自动匹配本地 Python 版本,无需手动挑选 _pyop.pyd

# 从 PyPI 安装(推荐)
pip install op-plugins

# 或从 GitHub Release 安装指定 wheel(将 <tag> 和 <wheel> 替换为实际文件名)
pip install https://github.com/WallBreaker2/op/releases/download/<tag>/<wheel>.whl

# 示例:64 位 Python 3.12
pip install https://github.com/WallBreaker2/op/releases/download/v1.0.0/op_plugins-1.0.0-cp312-cp312-win_amd64.whl

安装后使用 SWIG 绑定:

from pyop import libop

op = libop()
print("op version:", op.Ver())

注意:

  • 64 位 Python 请安装 win_amd64 wheel;32 位 Python / 32 位游戏场景请安装 win32 wheel
  • wheel 已内置 op_x64.dll / op_x86.dlltools.dll,无需单独下载 zip
  • 若仍使用 zip 分发,须确保 _pyop.pyd 与本地 Python 版本一致(如 cp312 对应 Python 3.12)

验证安装:

python -c "from pyop import libop; print(libop().Ver())"

免注册调用请参考 Wiki:

源码编译

环境要求:

  • Visual Studio 2022 或更新版本
  • CMake 3.24 或更新版本
  • Windows SDK 10.0.19041.0 或更新版本

推荐使用根目录 build.py

# 默认 Release + x64
python build.py

# 构建 x86
python build.py -a x86

# Debug
python build.py -t Debug

# 指定环境
python build.py -t Release -a x64 -g vs2022

Release 产物会安装到 bin/x86bin/x64

本地构建 pip wheel(推荐用脚本自动 bootstrap 依赖并设置 CMake 参数):

# 先确保已安装构建依赖
pip install scikit-build-core setuptools-scm

# 一键构建(默认 x64,自动检测 VS 版本)
./scripts/build_wheel.ps1

# 或手动:先 bootstrap,再 pip wheel
python build.py -t Release -a x64
pip wheel . --no-deps -w wheelhouse

# 本地模拟 CI 的单版本双架构 wheel 构建
pip install cibuildwheel==2.23.4
$env:CIBW_BUILD="cp312-*"
$env:CIBW_ARCHS_WINDOWS="AMD64"
$env:CIBW_BEFORE_BUILD_WINDOWS="powershell ./scripts/cibw_before_build.ps1"
$env:CIBW_ENVIRONMENT_WINDOWS='CMAKE_GENERATOR="Visual Studio 17 2022" CMAKE_ARGS="-A x64 -DOP_PYTHON_WHEEL=ON -DOP_BUILD_TESTS=OFF -Dbuild_swig_py=ON"'
python -m cibuildwheel --platform windows

$env:CIBW_ARCHS_WINDOWS="x86"
$env:CIBW_ENVIRONMENT_WINDOWS='CMAKE_GENERATOR="Visual Studio 17 2022" CMAKE_ARGS="-A Win32 -DOP_PYTHON_WHEEL=ON -DOP_BUILD_TESTS=OFF -Dbuild_swig_py=ON"'
python -m cibuildwheel --platform windows

pip wheel 报 BlackBone 未找到,说明尚未运行 python build.py./scripts/build_wheel.ps1 完成依赖引导。

社区

许可证

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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

op_plugins-0.4.7.6-cp312-cp312-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.12Windows x86-64

op_plugins-0.4.7.6-cp312-cp312-win32.whl (3.2 MB view details)

Uploaded CPython 3.12Windows x86

op_plugins-0.4.7.6-cp311-cp311-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.11Windows x86-64

op_plugins-0.4.7.6-cp311-cp311-win32.whl (3.2 MB view details)

Uploaded CPython 3.11Windows x86

op_plugins-0.4.7.6-cp310-cp310-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.10Windows x86-64

op_plugins-0.4.7.6-cp310-cp310-win32.whl (3.2 MB view details)

Uploaded CPython 3.10Windows x86

op_plugins-0.4.7.6-cp39-cp39-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.9Windows x86-64

op_plugins-0.4.7.6-cp39-cp39-win32.whl (3.2 MB view details)

Uploaded CPython 3.9Windows x86

File details

Details for the file op_plugins-0.4.7.6-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for op_plugins-0.4.7.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 7e16f0eb4445811f4b404a69c4d419d2f83f5b46f21f00681cccec6f0c470c22
MD5 7f2cca4b03d6e08e08574fe4426c4c11
BLAKE2b-256 42833ffa75b5b46274619e1e04a19f5068e2151926d79cc80f9823708d48af13

See more details on using hashes here.

File details

Details for the file op_plugins-0.4.7.6-cp312-cp312-win32.whl.

File metadata

  • Download URL: op_plugins-0.4.7.6-cp312-cp312-win32.whl
  • Upload date:
  • Size: 3.2 MB
  • Tags: CPython 3.12, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for op_plugins-0.4.7.6-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 65c905652b709dc7bcad1b1fae830b7e4e387c204ae0f03384f3202162243a2a
MD5 aafe31357cca190aebc82dd63fbd776b
BLAKE2b-256 f899adf7fecfdf877caa7b268932d94d35a86f2fcaaf0938608ef5599d62cd44

See more details on using hashes here.

File details

Details for the file op_plugins-0.4.7.6-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for op_plugins-0.4.7.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 489617c560b430a8a21d8999f54adc95affa6b064105054cb7a3dbbf22fd4b1a
MD5 1803f22335b85b0df871b425f8741269
BLAKE2b-256 db806257f1a92e4112bcc37ec4ba1b2b869a6e0eb961b0a065f61d9d4bdcc92f

See more details on using hashes here.

File details

Details for the file op_plugins-0.4.7.6-cp311-cp311-win32.whl.

File metadata

  • Download URL: op_plugins-0.4.7.6-cp311-cp311-win32.whl
  • Upload date:
  • Size: 3.2 MB
  • Tags: CPython 3.11, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for op_plugins-0.4.7.6-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 a49370abd79e24dbe6716fbc0829e28bb7e2443bd57b1d90011046345bbfac77
MD5 92f52860dce7d7bb6cdbab4f5341b9fc
BLAKE2b-256 f5cf8899c11766959f4f8a4760b1bee50c1ceb2b915f666959b96f0679de70b7

See more details on using hashes here.

File details

Details for the file op_plugins-0.4.7.6-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for op_plugins-0.4.7.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 6d092738ff239168d140432408c94c703ae557e70a2df833700e29f32766b991
MD5 2f2b6959198b1e3ee26b9c0e1ad3fd55
BLAKE2b-256 130a68b732dc6fdbe7f2357d8ad3d961f7180406c40c2a2df4dc69bff9ae16af

See more details on using hashes here.

File details

Details for the file op_plugins-0.4.7.6-cp310-cp310-win32.whl.

File metadata

  • Download URL: op_plugins-0.4.7.6-cp310-cp310-win32.whl
  • Upload date:
  • Size: 3.2 MB
  • Tags: CPython 3.10, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for op_plugins-0.4.7.6-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 bfded0c80c89c8eb9777fed6da1d22c181b7c12c17c5dfc4592d6a9409c9237b
MD5 751a117a34d8d43d2647fc304f576e63
BLAKE2b-256 84e9bc8a0f5b352af792e5b3957d41fef4cfee6b3be47ff45e0bf24e48815430

See more details on using hashes here.

File details

Details for the file op_plugins-0.4.7.6-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: op_plugins-0.4.7.6-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 4.0 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for op_plugins-0.4.7.6-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 7f10bc8e915a917aeed33bfff56d727332ecd5c1ff36dc6b334933ec944e2c36
MD5 d77589222e1d2f8367287472f40e306a
BLAKE2b-256 9eb347a7cc149d83b54a223b51d4031136e63debf0fc943582ef03a733c5f1b7

See more details on using hashes here.

File details

Details for the file op_plugins-0.4.7.6-cp39-cp39-win32.whl.

File metadata

  • Download URL: op_plugins-0.4.7.6-cp39-cp39-win32.whl
  • Upload date:
  • Size: 3.2 MB
  • Tags: CPython 3.9, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for op_plugins-0.4.7.6-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 5fa3dd57c03903a15de4c4217e60cf8cd2561ceb6a9c72224f95c12140f09d4d
MD5 5cc2dc41ef8efecd804f6f36fd12c508
BLAKE2b-256 9bdc656d5edfe655fabe0671627c4d88cd6e4ab6b8e9a669bf8fadc7f11cf743

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