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 后端。

YOLO 检测采用同类外部 HTTP 服务模式:OP 负责截图、读图和 HTTP 调用,YOLO11/YOLOv11 模型推理由独立服务完成。接口与返回格式见 YOLO HTTP 检测。 仓库内提供了最小服务样例:tools/op_yolo_engine.py

文档

主要能力

  • 窗口查询、窗口状态、窗口布局和后台绑定
  • 前台/后台鼠标键盘模拟
  • GDI、DXGI、WGC、DirectX、OpenGL 等截图方式
  • 找色、找图、图片输入源和内存图片输入
  • 点阵字库 OCR,兼容 OP 字库和大漠文本点阵字库格式
  • 独立 OCR HTTP 服务接入,支持 Tesseract、PaddleOCR 等通用/模型 OCR 后端
  • 独立 YOLO HTTP 检测服务接入,支持 YOLO11/YOLOv11 等外部检测后端
  • 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.8.3-cp312-cp312-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12Windows x86

op_plugins-0.4.8.3-cp311-cp311-win_amd64.whl (4.1 MB view details)

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11Windows x86

op_plugins-0.4.8.3-cp310-cp310-win_amd64.whl (4.1 MB view details)

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10Windows x86

op_plugins-0.4.8.3-cp39-cp39-win_amd64.whl (4.1 MB view details)

Uploaded CPython 3.9Windows x86-64

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

Uploaded CPython 3.9Windows x86

File details

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

File metadata

File hashes

Hashes for op_plugins-0.4.8.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f9f4d361d7591b2bc6ce57d254c295a9545f0346e87f42edd35845cc3337ec8e
MD5 3e4868fa0c9f9c2cd795c90a5559022c
BLAKE2b-256 6c1491de4e4efff9f7eed5f180c8f9fb8a70c3170263c98f0cd5ef97131986ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for op_plugins-0.4.8.3-cp312-cp312-win_amd64.whl:

Publisher: wheels.yml on WallBreaker2/op

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: op_plugins-0.4.8.3-cp312-cp312-win32.whl
  • Upload date:
  • Size: 3.2 MB
  • Tags: CPython 3.12, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for op_plugins-0.4.8.3-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 0e7f28a7e486245a1e03f0997b037da0cd566cca69d557ddb6629a278b5d373a
MD5 0f60d50d205e13edd17be285209783e6
BLAKE2b-256 9f555d91bf77a1cd721f5ca672514cb446b132aa01c0f5911ae23304056b2f8b

See more details on using hashes here.

Provenance

The following attestation bundles were made for op_plugins-0.4.8.3-cp312-cp312-win32.whl:

Publisher: wheels.yml on WallBreaker2/op

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for op_plugins-0.4.8.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ed44e9d06cb3634f74fa5594a59eebe322767a7dda45f51205600c06bc7d4993
MD5 6a311174289bb444408ea9e6678b11bf
BLAKE2b-256 5cbd1a843d6583bf732a44c0fc8aa3511652f6c1b57320a258671169391484e7

See more details on using hashes here.

Provenance

The following attestation bundles were made for op_plugins-0.4.8.3-cp311-cp311-win_amd64.whl:

Publisher: wheels.yml on WallBreaker2/op

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: op_plugins-0.4.8.3-cp311-cp311-win32.whl
  • Upload date:
  • Size: 3.2 MB
  • Tags: CPython 3.11, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for op_plugins-0.4.8.3-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 7ede8b7f7b35a8da96515c549c8df04c5d1aa467472ea3f8a3985e4b433a5678
MD5 3667dbc1ff2c29f4b7d5deeb82922f02
BLAKE2b-256 f5f8b1c1d0984c43a70c6c0d76a78b86e1e31187776e0d8f7e5a8e8909bb5a78

See more details on using hashes here.

Provenance

The following attestation bundles were made for op_plugins-0.4.8.3-cp311-cp311-win32.whl:

Publisher: wheels.yml on WallBreaker2/op

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for op_plugins-0.4.8.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c7d99e5d4021915625cd21cdbe441e615bffd8cfe6ba52177c5bbb115b157818
MD5 ce1015bb295af96f121839d6b35b9f02
BLAKE2b-256 abcd74297178bbbe26dd33252174bde6b54e460eca17625592f14d53f2961823

See more details on using hashes here.

Provenance

The following attestation bundles were made for op_plugins-0.4.8.3-cp310-cp310-win_amd64.whl:

Publisher: wheels.yml on WallBreaker2/op

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: op_plugins-0.4.8.3-cp310-cp310-win32.whl
  • Upload date:
  • Size: 3.2 MB
  • Tags: CPython 3.10, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for op_plugins-0.4.8.3-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 56ff88b921113c61e18f174e0d21fe68535dc67aec7077cd5eda3a58723f42a7
MD5 58072926a7bbf5c550a8949e9928c3f1
BLAKE2b-256 0d80158fade31444a5bcd9b735f49ba5a25c48854341c567c6cf008a09283edc

See more details on using hashes here.

Provenance

The following attestation bundles were made for op_plugins-0.4.8.3-cp310-cp310-win32.whl:

Publisher: wheels.yml on WallBreaker2/op

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: op_plugins-0.4.8.3-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 4.1 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for op_plugins-0.4.8.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 445449467c448075b8a136aae890d87b4a3b8cbfcead6fb2e0e65a74bd3c8d97
MD5 8c96503e6296bac64e57e2b132b5d040
BLAKE2b-256 ff361d9bf2f13fc68f4c11bda86c283756f8072e0d6ac0df2c03bc82535829d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for op_plugins-0.4.8.3-cp39-cp39-win_amd64.whl:

Publisher: wheels.yml on WallBreaker2/op

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: op_plugins-0.4.8.3-cp39-cp39-win32.whl
  • Upload date:
  • Size: 3.2 MB
  • Tags: CPython 3.9, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for op_plugins-0.4.8.3-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 953559a64000d36c94d7039be175b2d9c9fb44428abae19c5b263c7022c197ab
MD5 b7b171c905d78d75b3b9d17c0bf593bb
BLAKE2b-256 3c247771e59a7e871b2440fa6cf2fa0e7be0f7fa52293381c8ac25b5dd008229

See more details on using hashes here.

Provenance

The following attestation bundles were made for op_plugins-0.4.8.3-cp39-cp39-win32.whl:

Publisher: wheels.yml on WallBreaker2/op

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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