主题
查找文字 - FindStr
函数简介
查找指定文字的坐标,返回相对绑定窗口坐标,返回最优坐标。
接口名称
FindStrDLL调用
int FindStr(long ola, int x1, int y1, int x2, int y2, string str, string colorList, string dict, double matchVal, int* outX, int* outY);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| ola | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| x1 | 整数型 | 查找区域的左上角X坐标。 |
| y1 | 整数型 | 查找区域的左上角Y坐标。 |
| x2 | 整数型 | 查找区域的右下角X坐标。 |
| y2 | 整数型 | 查找区域的右下角Y坐标。 |
| str | 字符串 | 待查找的字符串,可以是字符串组合,比如"str1|str2|str3",中间用"|"来分割字符串 |
| colorList | 字符串 | 颜色模型配置字符串,用于限定图像匹配中的颜色范围,格式说明见 颜色模型说明 - ColorModel。JSON格式示例:[{"StartColor":"3278FA","EndColor":"6496FF","Type":0}];简化格式示例:`3278FA-000000。 |
| dict | 字符串 | 字库名称,为空时搜索所有字库;多个字库用 | 分割,如 dict1|dict2 |
| matchVal | 双精度浮点数 | 相似度,如 0.85,最大为 1。 |
| outX | 整数型指针 | 输出参数,返回的X坐标。 |
| outY | 整数型指针 | 输出参数,返回的Y坐标。 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
// 0,0,0,0 表示绑定窗口整个客户区
string pos = ola.FindStr(0, 0, 0, 0, "确定", "000000", 0.9);
// 返回坐标字符串,格式见 FindStr 文档csharp
using OLAPlug;
var ola = new OLAPlugServer();
// 0,0,0,0 表示绑定窗口整个客户区
string pos = ola.FindStr(0, 0, 0, 0, "确定", "000000", 0.9);
// 返回坐标字符串,格式见 FindStr 文档python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
# 0,0,0,0 表示绑定窗口整个客户区
pos = ola.FindStr(0, 0, 0, 0, "确定", "000000", 0.9)
# 返回坐标字符串,格式见 FindStr 文档java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
// 0,0,0,0 表示绑定窗口整个客户区
String pos = ola.FindStr(0, 0, 0, 0, "确定", "000000", 0.9);
// 返回坐标字符串,格式见 FindStr 文档cpp
var ola = com("OlaPlug.OlaSoft")
// 0,0,0,0 表示绑定窗口整个客户区
var pos = ola.FindStr(0, 0, 0, 0, "确定", "000000", 0.9)
// 返回坐标字符串,格式见 FindStr 文档vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
' 0,0,0,0 表示绑定窗口整个客户区
pos = ola.FindStr(0, 0, 0, 0, "确定", "000000", 0.9)
' 返回坐标字符串,格式见 FindStr 文档text
.局部变量 ola, OLAPlug
ola.创建 ()
' 0,0,0,0 表示绑定窗口整个客户区
pos = ola.FindStr(0, 0, 0, 0, “确定“, “000000“, 0.9)
' 返回坐标字符串,格式见 FindStr 文档aardio
import OLAPlugServer;
var ola = OLAPlugServer();
// 0,0,0,0 表示绑定窗口整个客户区
var pos = ola.FindStr(0, 0, 0, 0, "确定", "000000", 0.9);
// 返回坐标字符串,格式见 FindStr 文档text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
// 0,0,0,0 表示绑定窗口整个客户区
文本型 pos = ola.FindStr(0, 0, 0, 0, "确定", "000000", 0.9)
// 返回坐标字符串,格式见 FindStr 文档cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
// 0,0,0,0 表示绑定窗口整个客户区
string pos = ola.FindStr(0, 0, 0, 0, "确定", "000000", 0.9);
// 返回坐标字符串,格式见 FindStr 文档原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
long posPtr = FindStr(instance, 0, 0, 0, 0, "确定", "000000", 0.9);
if (posPtr != 0) {
char pos[512] = {0};
GetStringFromPtr(posPtr, pos, sizeof(pos));
FreeStringPtr(posPtr);
}csharp
using System.Runtime.InteropServices;
using System.Text;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringFromPtr(long ptr, StringBuilder lpString, int size);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int FreeStringPtr(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringSize(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
long instance = CreateCOLAPlugInterFace();
long posPtr = FindStr(instance, 0, 0, 0, 0, "确定", "000000", 0.9);
if (posPtr != 0) {
StringBuilder pos = new StringBuilder(GetStringSize(posPtr) + 1);
GetStringFromPtr(posPtr, pos, pos.Capacity);
FreeStringPtr(posPtr);
string posStr = pos.ToString();
}python
from ctypes import CDLL, c_int, c_int64, create_string_buffer
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
posPtr = FindStr(instance, 0, 0, 0, 0, "确定", "000000", 0.9)
if posPtr:
buf = create_string_buffer(512)
ola.GetStringFromPtr(posPtr, buf, 512)
ola.FreeStringPtr(posPtr)
pos = buf.value.decode("utf-8")返回值
| 返回值 | 说明 |
|---|---|
1 | 成功。 |
0 | 失败。 |
