找图快速模式(默认开)。on=1:模板加载时挑 8 个高区分度像素当粗筛,找图先用这 8 点判断「这个位置连大致像都算不上」,全不匹配直接跳过,不用扫满整张模板——未命中场景快 10 倍以上(1024x768 全屏找图 170ms 降到 13ms),实测 48 个真实区块 0 误杀。on=0:关掉粗筛,纯全模板扫描,结果与旧版逐位一致只用于校验,慢很多
| 参数名 | 方向 | 类型 | 说明 |
|---|---|---|---|
on | [in] | long | 找图快速模式开关:1=开(默认,模板预挑高区分度像素粗筛)0=关 |
// 说明:本示例为完整 x64 控制台工程,整段复制覆盖新建控制台工程的 main.cpp 即可编译运行。
// 1. VS2019 新建「控制台应用」,项目属性 -> 平台选 x64,才能加载 64 位 DLL。
// 2. 项目属性 -> C/C++ -> 预编译头 -> 改为「不使用预编译头」,否则默认找 pch.h 会报 C1010。
// 3. 把 x64Game-Plug.dll 放到 exe 同目录(#import 与免注册加载都需要)。
// 4. 源码保存为 UTF-8 带 BOM,避免中文乱码;全站用 regsvr32 注册也可(需管理员)。
#include <iostream>
#include <clocale>
#include <windows.h>
#include <comdef.h>
// 免注册加载:用 IGamePlug 智能指针装载
// rename 是为避开 windows.h 的 FindWindow 宏冲突,接口里的 FindWindow 在 C++ 侧改名为 FindWindowGP
#import "x64Game-Plug.dll" no_namespace rename("FindWindow", "FindWindowGP")
static HMODULE g_hDll = NULL;
static IGamePlugPtr g_plug;
// ---------- 免注册:加载 DLL 并创建对象(发布时把 DLL 放 exe 同目录)----------
static bool LoadPlug() {
const wchar_t* paths[] = {
L"x64Game-Plug.dll",
L"..\x64Game-Plug.dll"
};
for (int i = 0; i < (int)(sizeof(paths) / sizeof(paths[0])); ++i) {
g_hDll = ::LoadLibraryW(paths[i]);
if (g_hDll) break;
}
if (!g_hDll) {
std::cout << "LoadLibrary failed: put x64Game-Plug.dll next to the exe" << std::endl;
return false;
}
typedef HRESULT (__stdcall *GamePlugCreateFn)(IGamePlug**);
GamePlugCreateFn fn = (GamePlugCreateFn)::GetProcAddress(g_hDll, "GamePlugCreate");
if (!fn) { std::cout << "GetProcAddress GamePlugCreate failed" << std::endl; return false; }
HRESULT hr = fn(&g_plug);
if (FAILED(hr)) { std::cout << "GamePlugCreate failed: 0x" << std::hex << hr << std::endl; return false; }
return true;
}
int main() {
if (!LoadPlug()) { system("pause"); return 1; }
// 授权(收费功能需先传入授权码,去 https://www.game-plug.cn/ 获取)
g_plug->SetUsername(_bstr_t(L"U12-XXXXXXXXXXXXXXXX"));
// ---------- 调用插件本命令方法如下 ----------
try {
long on = 1;
VARIANT_BOOL v = g_plug->SetFindPicFast(on);
std::cout << "结果: " << (v ? 1 : 0) << std::endl;
} catch (_com_error& e) {
std::wcout << L"COM error: " << e.ErrorMessage() << std::endl;
}
g_plug->Release();
system("pause");
return 0;
}
返回 1 表示设置成功,0 表示失败。