使用python编写AutoHotKey/AHK

1,846 阅读1分钟
  1. 安装python环境

    参考:www.liaoxuefeng.com/wiki/101695…

    Requires Python 3.6+

    Async API requires Python 3.8+

  2. 安装Python wrapper around AHK

    github.com/spyoungtech…

    pip install ahk
    
  3. 安装最新版的AHK,旧版运行时可能触发莫名错误

    github.com/Lexikos/Aut…

    其他版本

    www.autohotkey.com/download/

    AHK中文文档

    wyagd001.github.io/zh-cn/docs/…

  4. 运行

    from ahk import AHK
    
    ahk = AHK(executable_path='path/to/lastest/version/of/ahk.exe')
    
    ahk.mouse_move(x=100, y=100, blocking=True)  # Blocks until mouse finishes moving (the default)
    ahk.mouse_move(x=150, y=150, speed=10, blocking=True) # Moves the mouse to x, y taking 'speed' seconds to move
    print(ahk.mouse_position)  #  (150, 150)