我在 AutoIt 中找到了这个带有包装器的图像搜索 dll 库,它为我解决了这个问题。这不是您能找到的最强大的解决方案,但对于大多数人来说,它运行良好。它使用 Chrome 的不可识别控件对我有用。
非常简单的使用:
$result = _ImageSearchArea("ButtonImagePath.png", $tolerance, $Left, $Top, $Right, $Bottom, $x, $y, 100)
其中 $x 和 $y 是结果位置,因此您可以在之后发送点击。使用截图工具获取图像也非常容易。更多信息在这里和这里。
编辑:如果你想在 C# 中使用它,它也可以与它的 dll 进行互操作:(它对于自动单击鼠标等未识别的按钮非常有用)
class ImageHelper
{
[DllImport("ImageSearchDLL.dll")]
private static extern IntPtr ImageSearch(int x, int y, int right, int bottom, [MarshalAs(UnmanagedType.LPStr)]string imagePath);
private static String[] UseImageSearch()
{
int right = Screen.PrimaryScreen.WorkingArea.Right;
int bottom = Screen.PrimaryScreen.WorkingArea.Bottom;
IntPtr result = ImageSearch(0, 0, right, bottom, "imageFileName.png");
String res = Marshal.PtrToStringAnsi(result);
if (res[0] == '0') return null;//not found
String[] data = res.Split('|');
int x;
int y;
int.TryParse(data[1], out x);
int.TryParse(data[2], out y);
//0->found, 1->x, 2->y, 3->image width, 4->image height
Cursor.Position = new Point(x, y);
return data;
}
}