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、YOLO HTTP 检测和进程内存读写放在同一套接口里,方便脚本工具和桌面自动化程序直接调用。

核心代码使用 C++ 实现,提供 COM、C API、Python 和 Go 绑定,支持 x86/x64。截图后端覆盖普通窗口、GDI、DXGI、WGC、DirectX Hook、OpenGL 和 OpenGL ES;字库、图片模板可以从本地文件加载,也可以从内存加载,适合把资源随程序一起打包。

OCR 目前有两条路线:固定字体场景使用点阵字库,兼容 OP 二进制字库和大漠文本点阵字库;通用 OCR 可以接入独立 HTTP 服务 op_ocr_engine,由 Tesseract、PaddleOCR 等后端完成识别。

YOLO 检测同样走外部 HTTP 服务模式。OP 负责截图、读图和请求封装,模型推理由独立服务完成。接口格式见 YOLO HTTP 检测,仓库里也放了一个最小服务样例:tools/op_yolo_engine.py

文档

主要能力

  • 窗口枚举、进程查询、窗口状态控制、批量窗口布局
  • 普通绑定、后台绑定、显示句柄和输入句柄分离绑定
  • GDI、DXGI、WGC、DX Hook、OpenGL、OpenGL ES 等截图方式
  • 前台/后台鼠标键盘模拟,支持平滑移动、轨迹移动和 DX 输入锁定
  • 找色、找图、透明图片模板、OpenCV 模板匹配和特征匹配
  • 点阵字库 OCR,支持本地字库和内存字库
  • OCR / YOLO HTTP 服务接入
  • C API、COM、Python、Go 等调用方式
  • 进程内存读写、汇编调用和常用算法工具

目录概览

op/
├─ libop/            核心 C++ 源码
│  ├─ op/            op::Op 对外接口的分文件实现
│  ├─ c_api/         C API 封装
│  ├─ com/           COM 组件、IDL 和自动化接口实现
│  ├─ binding/       窗口绑定和后台模式调度
│  ├─ capture/       GDI、DXGI、WGC、Hook 等截图后端
│  ├─ hook/          远端注入、显示 hook、输入 hook 和共享帧写入
│  ├─ input/         鼠标、键盘输入后端
│  ├─ image/         图片加载、找色、找图和图像搜索服务
│  ├─ ocr/           字库管理和 OCR 识别
│  ├─ opencv/        OpenCV 桥接、模板匹配和图像处理
│  ├─ window/        窗口、进程和 DLL 注入相关能力
│  ├─ base/          基础类型、运行环境和工具函数
│  ├─ ipc/           共享内存、互斥量、管道等进程间通信封装
│  ├─ memory/        目标进程内存读写
│  ├─ network/       HTTP 客户端等网络辅助能力
│  ├─ algorithm/     内部算法与通用计算逻辑
│  └─ yolo/          YOLO 检测器封装
├─ include/          对外头文件
├─ bindings/         C API 的 Python、Go 包装
├─ swig/             SWIG 绑定生成文件
├─ python/           `pyop` Python 包源码
├─ tools/            免注册加载工具和 YOLO 服务样例
├─ examples/         本地示例和测试资源
├─ tests/            C++ 单元测试和集成测试
├─ doc/              项目内补充文档和流程图
├─ scripts/          wheel 构建脚本
├─ ci/               CI triplet 和辅助配置
├─ 3rd_party/        第三方源码或本地依赖
├─ build.py          推荐的一键构建入口
└─ CMakeLists.txt    CMake 工程入口

快速开始

下载 Release 后,根据宿主程序位数使用对应 DLL。COM 方式需要注册:

# 32 位宿主程序
regsvr32 .\op_x86.dll

# 64 位宿主程序
regsvr32 .\op_x64.dll

Python 通过 COM 调用:

from win32com.client import Dispatch

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

免注册调用请看 Wiki:

Python

op-plugins wheel 面向直接使用 pyop 的用户,支持 Python 3.9-3.12,提供 win32win_amd64 两种架构:

pip install op-plugins
from pyop import Op

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

如果从 Release 安装指定 wheel,把 <tag><wheel> 换成实际文件名:

pip install https://github.com/WallBreaker2/op/releases/download/<tag>/<wheel>.whl

注意:

  • 64 位 Python 使用 win_amd64 wheel,32 位 Python 使用 win32 wheel
  • wheel 已内置对应架构的 OP 运行文件,不需要再手动复制 zip 里的 DLL
  • bindings/python 是基于 ctypes 的 C API 包装,和 SWIG 版 pyop 相互独立,适合需要直接调用 op_c_api_*.dll 的场景

验证安装:

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

源码编译

环境要求:

  • Windows 10 或更新版本
  • Visual Studio 2022 或更新版本
  • CMake 3.24 或更新版本
  • Python 3.12(用于构建脚本、SWIG 绑定和测试工具)

推荐使用根目录 build.py

# 当前 CI 使用的 Release x64 构建
python build.py -g vs2026 -t Release -a x64

# 构建 x86
python build.py -g vs2026 -t Release -a x86

# Debug
python build.py -g vs2026 -t Debug -a x64

# 如果本机是 VS2022,可以把 -g 改成 vs2022
python build.py -g vs2022 -t Release -a x64

Release 产物会安装到 bin/x86bin/x64。发布包通常包含:

op_x86.dll / op_x64.dll
op_c_api_x86.dll / op_c_api_x64.dll
tools.dll
_pyop.pyd
pyop.py
lib/op_c_api_x86.lib / lib/op_c_api_x64.lib

本地构建 wheel:

pip install scikit-build-core setuptools-scm
.\scripts\build_wheel.ps1

如果手动构建,先跑一次 build.py 完成依赖引导:

python build.py -g vs2026 -t Release -a x64
pip wheel . --no-deps -w wheelhouse

社区

许可证

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.2-cp312-cp312-win_amd64.whl (4.1 MB view details)

Uploaded CPython 3.12Windows x86-64

op_plugins-0.4.8.2-cp312-cp312-win32.whl (3.3 MB view details)

Uploaded CPython 3.12Windows x86

op_plugins-0.4.8.2-cp311-cp311-win_amd64.whl (4.2 MB view details)

Uploaded CPython 3.11Windows x86-64

op_plugins-0.4.8.2-cp311-cp311-win32.whl (3.3 MB view details)

Uploaded CPython 3.11Windows x86

op_plugins-0.4.8.2-cp310-cp310-win_amd64.whl (4.2 MB view details)

Uploaded CPython 3.10Windows x86-64

op_plugins-0.4.8.2-cp310-cp310-win32.whl (3.3 MB view details)

Uploaded CPython 3.10Windows x86

op_plugins-0.4.8.2-cp39-cp39-win_amd64.whl (4.2 MB view details)

Uploaded CPython 3.9Windows x86-64

op_plugins-0.4.8.2-cp39-cp39-win32.whl (3.3 MB view details)

Uploaded CPython 3.9Windows x86

File details

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

File metadata

File hashes

Hashes for op_plugins-0.4.8.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 22b4e987fa7a988bb3784f83ec59405f17c41def6c41f23bdc6ed59a6005dfa5
MD5 e55abd16da5e367d9832dfc0bd046793
BLAKE2b-256 f14281f320b0a15308a21428b73bba059a4c793703ac5d5db7b0ba48f5b72c7b

See more details on using hashes here.

Provenance

The following attestation bundles were made for op_plugins-0.4.8.2-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.2-cp312-cp312-win32.whl.

File metadata

  • Download URL: op_plugins-0.4.8.2-cp312-cp312-win32.whl
  • Upload date:
  • Size: 3.3 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.2-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 b1cb6813fd14c636dbe15131222835e0f2c9fe479d693ebf908ede45910dd0ca
MD5 2b71b66887104380ca7a5669a1b942c5
BLAKE2b-256 0296c130190097f26e35d4bfba3d438dc4da888a3ebf52f7b5a1db5c236b2b8f

See more details on using hashes here.

Provenance

The following attestation bundles were made for op_plugins-0.4.8.2-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.2-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for op_plugins-0.4.8.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4fabae89e1d072c5d5536354662f173d0edbc912db6becc8298af9f391955ed7
MD5 210967a1fc1d1d57487096bd40d3b92d
BLAKE2b-256 471348d48384a9ec8a72133874ece0faec26f6f657fc580db90db4f62da5dc4f

See more details on using hashes here.

Provenance

The following attestation bundles were made for op_plugins-0.4.8.2-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.2-cp311-cp311-win32.whl.

File metadata

  • Download URL: op_plugins-0.4.8.2-cp311-cp311-win32.whl
  • Upload date:
  • Size: 3.3 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.2-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 8272ca30c352c0af643e70e7386a83d8a71496821b8eb61e3f48960a3918cd4f
MD5 af996ecb09f89aae5c714a5c856a731b
BLAKE2b-256 ec9b98629c4ab23ac70771d0f932a040eef4d0e9c08c86c9ba1264eda15d7ea3

See more details on using hashes here.

Provenance

The following attestation bundles were made for op_plugins-0.4.8.2-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.2-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for op_plugins-0.4.8.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 4522cc2e7a92b30eaa61ac9c196563089e9b81846ad4cd7f9189e7c41ad377ed
MD5 a36b519400394b3f2c8bf142d3ae2058
BLAKE2b-256 645d9bc1ab789b478e7f442b18b4472c2823812b46ceda07d447b5f08a143448

See more details on using hashes here.

Provenance

The following attestation bundles were made for op_plugins-0.4.8.2-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.2-cp310-cp310-win32.whl.

File metadata

  • Download URL: op_plugins-0.4.8.2-cp310-cp310-win32.whl
  • Upload date:
  • Size: 3.3 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.2-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 025aa8e6980aa30c3288c622cb24f1efa811025eefae49b7498cccae054b482d
MD5 8687214959ecbffcf343bca9394b2064
BLAKE2b-256 585bfd3cdb3033710ad6ec05c4eea3498e63daa240325e3f34b013bc36a2ec3f

See more details on using hashes here.

Provenance

The following attestation bundles were made for op_plugins-0.4.8.2-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.2-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: op_plugins-0.4.8.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 4.2 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.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 29100049a958d0fef9d5a81312fccb17f2f8f70e8b915e00b41e4795c6b98db3
MD5 ca691884b42b3e4120ab406d18e6dbd8
BLAKE2b-256 e8f1346b7a78e4a5b4bc923529d58e123f5696ba65bf66ac80e127f6a19e85b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for op_plugins-0.4.8.2-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.2-cp39-cp39-win32.whl.

File metadata

  • Download URL: op_plugins-0.4.8.2-cp39-cp39-win32.whl
  • Upload date:
  • Size: 3.3 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.2-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 643b7dd713e527fecfca042d543bee25e6872f1870e564e18f0a03b94fb8e349
MD5 95ea678117d847e139e6e4c669923b52
BLAKE2b-256 bdc1b5c1ab7679b7c64808dae38dc55fe12e05a2f4842590698976f779b6a429

See more details on using hashes here.

Provenance

The following attestation bundles were made for op_plugins-0.4.8.2-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