ImageSearch 命令失败
ImageSearch command failing
我正在尝试创建一个热键,它将找到 google 工作表 "tools" 菜单,单击它,向下移动几个像素并单击脚本编辑器。我可以在 google 工作表中执行此操作,但它没有通用键绑定,我必须制作一个宏,我宁愿它只是通用的。
SC163::
{
ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, C:\Users\xx\Documents\AHK Scripts\gsheets-tools.bmp
if ErrorLevel = 2
tooltip Could not conduct the search.
else if ErrorLevel = 1
tooltip Image could not be found on the screen.
else
{
mousemove, %FoundX%, %FoundY%, 50
tooltip The image was found at %FoundX%x%FoundY%.
}
return
}
在我对整个图像名称进行硬编码之前,它一直在抛出错误 2。现在它只会抛出错误 1,即使我打开了三份工作表(每个显示器一个)。 BMP 不是这里使用的最佳格式吗?我尝试使用
ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *n30 C:\Users\xx\Documents\AHK Scripts\gsheets-tools.bmp
看看添加该津贴是否有帮助,但失败了。正确使用图像搜索有什么技巧吗?这不是什么复杂的游戏功能,只是想找到一个工具栏并点击它!
尝试将 *n30
更改为 *30
。
此外,默认情况下,ImageSearch
坐标是每个活动 window 而不是整个桌面,因此使用 A_ScreenWidth
和 A_SreeenHeight
可能会有问题。如果 window 在您的主屏幕上最大化,这不是问题,但如果它未最大化或在不同分辨率的屏幕上,则可能会出现问题。如果它没有最大化,它可能正在搜索超出显示区域的区域,这可能是个问题。
可能另一个问题(未验证)与 Windows 缩放有关。很多时候 2160p 显示器默认缩放比例为 200%(或者是 150%?w/e)。
由于您使用的是 BMP 图像,因此您可能需要验证它是否已保存为 16 位或更高版本。
帮助文件中的重要引述:
All operating systems support GIF, JPG, BMP, ICO, CUR, and ANI images (BMP images must be 16-bit or higher).
. . .
The region to be searched must be visible; in other words, it is not possible to search a region of a window hidden behind another window. By contrast, images that lie partially beneath the mouse cursor can usually be detected. The exception to this is game cursors, which in most cases will obstruct any images beneath them.
我建议您将其用于图片搜索
https://www.youtube.com/watch?v=aWRAtvJq9ZE
非常简单而且效果很好!
我正在尝试创建一个热键,它将找到 google 工作表 "tools" 菜单,单击它,向下移动几个像素并单击脚本编辑器。我可以在 google 工作表中执行此操作,但它没有通用键绑定,我必须制作一个宏,我宁愿它只是通用的。
SC163::
{
ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, C:\Users\xx\Documents\AHK Scripts\gsheets-tools.bmp
if ErrorLevel = 2
tooltip Could not conduct the search.
else if ErrorLevel = 1
tooltip Image could not be found on the screen.
else
{
mousemove, %FoundX%, %FoundY%, 50
tooltip The image was found at %FoundX%x%FoundY%.
}
return
}
在我对整个图像名称进行硬编码之前,它一直在抛出错误 2。现在它只会抛出错误 1,即使我打开了三份工作表(每个显示器一个)。 BMP 不是这里使用的最佳格式吗?我尝试使用
ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *n30 C:\Users\xx\Documents\AHK Scripts\gsheets-tools.bmp
看看添加该津贴是否有帮助,但失败了。正确使用图像搜索有什么技巧吗?这不是什么复杂的游戏功能,只是想找到一个工具栏并点击它!
尝试将 *n30
更改为 *30
。
此外,默认情况下,ImageSearch
坐标是每个活动 window 而不是整个桌面,因此使用 A_ScreenWidth
和 A_SreeenHeight
可能会有问题。如果 window 在您的主屏幕上最大化,这不是问题,但如果它未最大化或在不同分辨率的屏幕上,则可能会出现问题。如果它没有最大化,它可能正在搜索超出显示区域的区域,这可能是个问题。
可能另一个问题(未验证)与 Windows 缩放有关。很多时候 2160p 显示器默认缩放比例为 200%(或者是 150%?w/e)。
由于您使用的是 BMP 图像,因此您可能需要验证它是否已保存为 16 位或更高版本。
帮助文件中的重要引述:
All operating systems support GIF, JPG, BMP, ICO, CUR, and ANI images (BMP images must be 16-bit or higher).
. . .
The region to be searched must be visible; in other words, it is not possible to search a region of a window hidden behind another window. By contrast, images that lie partially beneath the mouse cursor can usually be detected. The exception to this is game cursors, which in most cases will obstruct any images beneath them.
我建议您将其用于图片搜索 https://www.youtube.com/watch?v=aWRAtvJq9ZE 非常简单而且效果很好!