N_QT 图色脚本

QT with op 插件

OP(operator & open)是一个开源插件(类似大漠插件).主要功能有:Windows消息模拟,后台截图,找图,字符识别(OCR)等。使用c++编写,源代码可编译为32/64位dll.op插件提供了两类接口:1)原生c++接口,可以让c/c++开发者方便调用;2)com接口,支持大多数编译型语言(c++,c#,vb,delphi等 以及脚本语言(python,lua等)的调用

git 项目 相关文档 相关文档 ocr

实例

头文件和lib

CMakeLists.txt

# 设置头文件目录 相当于指定gcc的-I参数
include_directories(
  op/lib/include/
)
# 设置链接库搜索目录 相当于gcc的-L参数
link_directories(
    op/lib/x64/
)
 
# 追加 链接库
target_link_libraries(op-call Qt${QT_VERSION_MAJOR}::Core
 "op_x64" "tools" # 可以忽略 .lib 后缀
)

测试

#include <QCoreApplication>
#include <iostream>
#include "libop.h"
 
void printHwndInfo(libop *op, long hwnd){
    std::cout<<"==========="<<hwnd<<"============="<<std::endl;
    long ret = 0;
    std::wstring title;
    op->GetWindowTitle(hwnd,title);
    std::wcout<<"窗口 title: "<<title<<std::endl;
 
    std::wstring class_name;
    op->GetWindowClass(hwnd, class_name);
    std::wcout<<"窗口 class_name: "<<title<<std::endl;
    long x1,y1,x2,y2;
    op->GetWindowRect(hwnd, &x1,&y1,&x2,&y2,&ret);
    std::cout<<"窗口 rect: "<<x1<<","<<y1<<" "<<x2<<", "<<y2<<std::endl;
 
    op->GetWindowProcessId(hwnd, &ret);
    std::wcout<<"窗口所属 Process: "<<ret;
    std::wstring processDesc;
    op->GetProcessInfo(ret, processDesc);
    //格式: 进程名|进程路径|cpu|内存"
    std::wcout<<", detail: "<<processDesc<<std::endl;
}
int main(int argc, char *argv[]){
    QCoreApplication a(argc, argv);
    libop *op = new libop;
    long *ret = new long;
 
    long hwnd = 0x00EB045E;
    /// 截图
    op->BindWindow(hwnd,L"normal",L"windows",L"windows",0, ret);
    std::cout<<"BindWindow: "<<*ret<<std::endl;
    if(*ret){
        std::cout<<"绑定成功"<<std::endl;
        op->CapturePre(L"E:/yang/cap.png", ret);
        std::cout<<"CapturePre: "<<*ret<<std::endl;
    }
    return a.exec();
}

注意 复制 run dll, 必须Release编译

项目归档

qt 项目归档

python 使用

from ctypes import *
 
 
instance = CDLL('./libop/op_x64.dll')
instance.OP_WaitKey.argtypes= [c_int,c_int]
instance.restype = c_long
res = 66
print( instance.OP_WaitKey(res, 10000) )

项目归档

Transclude of hello-op.zip
Transclude of op-free-reg.zip

封装为 Node LoadLibrary ?

封装一下给 node , 用js写辅助, 美滋滋.

插件是用 C++ 编写的动态链接共享对象。 require() 函数可以将插件加载为普通的 Node.js 模块。 插件提供了 JavaScript 和 C/C++ 库之间的接口。

实现插件有三种选择: Node-API、nan,或直接使用内部 V8、libuv 和 Node.js 库。 除非需要直接访问 Node-API 未暴露的功能,否则请使用 Node-API。 有关 Node-API 的更多信息,请参阅 使用 Node-API 的 C/C++ 插件。

官文 C/C++插件(使用Node-API) 官方示例-仓库

巨难用!!! 还不如用C++的js引擎反过来调用.

qt 项目归档, 待完善 qt 项目归档, 待待完善