【发布时间】:2021-12-01 14:31:16
【问题描述】:
我正在考虑 UI 自动化。
pyAutoGUI (Python) 的图像搜索与 Autohotkey 相比似乎有点慢。
我猜 pyautoGUI 尝试从全屏中查找图像 但自动热键尝试从特定区域查找图像 因为我使用“winactive”选项。
谁能给个建议?
【问题讨论】:
标签: python autohotkey pyautogui
我正在考虑 UI 自动化。
pyAutoGUI (Python) 的图像搜索与 Autohotkey 相比似乎有点慢。
我猜 pyautoGUI 尝试从全屏中查找图像 但自动热键尝试从特定区域查找图像 因为我使用“winactive”选项。
谁能给个建议?
【问题讨论】:
标签: python autohotkey pyautogui
(假设您使用的是 Windows)
AutoHotkey/AHK 在这里是更好的选择, 因为它不像 python 那样依赖依赖,并且性能更好,即使资源很少。
特定区域,因为我使用“winactive”选项
没必要,全屏搜索..[ImageSearch AHK Docs]
例子,
IMG_PATH := "C:\Users\YOURNAME\Desktop\gLogo.bmp"
CoordMode Pixel ; Interprets the coordinates below as relative to the screen rather than the active window.
ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 %IMG_PATH%
if (ErrorLevel = 2)
MsgBox Could not conduct the search.
else if (ErrorLevel = 1)
MsgBox Icon could not be found on the screen.
else
MouseMove, %FoundX%,%FoundY%
它不必是 .bmp,您可以使用任何压缩率最低的图像。
毕竟比起pyautogui,AHK写起来要简单得多。
【讨论】: