【问题标题】:Comparing image searching with AHK or pyAutoGUI?将图像搜索与 AHK 或 pyAutoGUI 进行比较?
【发布时间】:2021-12-01 14:31:16
【问题描述】:

我正在考虑 UI 自动化。

pyAutoGUI (Python) 的图像搜索与 Autohotkey 相比似乎有点慢。

我猜 pyautoGUI 尝试从全屏中查找图像 但自动热键尝试从特定区域查找图像 因为我使用“winactive”选项。

谁能给个建议?

【问题讨论】:

    标签: python autohotkey pyautogui


    【解决方案1】:

    (假设您使用的是 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写起来要简单得多。

    【讨论】:

      猜你喜欢
      • 2012-12-02
      • 2015-11-01
      • 2014-05-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-16
      • 2016-10-02
      • 1970-01-01
      相关资源
      最近更新 更多