AutoHotkey是一个Windows平台脚本语言,常常用于制作游戏外挂

功能

  • 启动程序,打开文件
  • 获得或产生系统状态,音量(状态,调节),搜索屏幕上的图像或像素(获得坐标),鼠标(位置,悬停视窗对象,移动),键盘(热键(快捷键),热字符串(键盘输入序列),上下文热键),游戏杆按钮
  • 创建图形用户界面
  • 剪贴板操作,程序窗口操作

这里我们来学习如何使用

下载

点击下载Autohotkey

官网有两个版本,有非常大的区别

​ image-20261008083922375

这个是因为历史原因

  • AutoHotkey 1.0- 被称为 AutoHotkey Basic 或者 AutoHotkey Classic 或者 AutoHotkey Vanilla
  • AutoHotkey_H 是由 HotkeyIt 合并了原有AutoHotkey.dll 并在 AutoHotkey_L 及 AutoHotkey v2 的基础上开发的分支。
  • AutoHotkey_L 主要由 Lexikos 在 AutoHotkey Basic 基础上开发的分支,但是现在已经变成(也被称为) AutoHotkey 1.1的主要版本
  • AutoHotkey v2由 Lexikos 基于AutoHotkey_L代码开发,已于2022年12月20日正式发布,语法不完全兼容 AutoHotkey 1.1,2023年1月22正式成为官方的默认版本

这里不要下载v1版本,目前此版本已停止维护

v2和v1版本的最大区别就是语法完全不兼容,而且v1版本似乎存在bug比如内存泄漏

使用方法

软件结构

autohotkey的脚本语言是ahk,包括软件的本体也是由ahk语言编写

ahk
1234567891011121314151617181920212223242526272829303132333435363738394041424344
AutoHotkey_2.0.19
├── Compiler
│   └── Ahk2Exe.exe
├── UX
│   ├── Templates
│   │   └── Minimal for v2.ahk
│   ├── inc
│   │   ├── CommandLineToArgs.ahk
│   │   ├── CreateAppShortcut.ahk
│   │   ├── EnableUIAccess.ahk
│   │   ├── GetGitHubReleaseAssetURL.ahk
│   │   ├── HashFile.ahk
│   │   ├── README.txt
│   │   ├── ShellRun.ahk
│   │   ├── bounce-v1.ahk
│   │   ├── common.ahk
│   │   ├── config.ahk
│   │   ├── identify.ahk
│   │   ├── identify_regex.ahk
│   │   ├── launcher-common.ahk
│   │   ├── spy.ico
│   │   └── ui-base.ahk
│   ├── AutoHotkeyUX.exe
│   ├── WindowSpy.ahk
│   ├── install-ahk2exe.ahk
│   ├── install-version.ahk
│   ├── install.ahk
│   ├── installed-files.csv
│   ├── launcher.ahk
│   ├── reload-v1.ahk
│   ├── reset-assoc.ahk
│   ├── ui-dash.ahk
│   ├── ui-editor.ahk
│   ├── ui-launcherconfig.ahk
│   ├── ui-newscript.ahk
│   ├── ui-setup.ahk
│   └── ui-uninstall.ahk
├── v2
│   ├── AutoHotkey.chm
│   ├── AutoHotkey.exe
│   ├── AutoHotkey32.exe
│   └── AutoHotkey64.exe
├── WindowSpy.ahk
└── license.txt

我们创建我们自己的ahk脚本并设置默认打开软件为autohotkey即可

启动脚本

我们只需双击ahk脚本就能启动程序,此时Windows右下角任务栏就能看到

​ image-20261008085207515

VScode插件

常见的插件如下,不过注意区分V1的插件和V2的插件

​ image-20261008085809959

Zed插件

目前只有一个开发者制作了V1版本的

​ image-20261008090749639

Ahk2Exe打包插件

​ image-20261008092704292

我们点击compile

选择ahk文件以及软件logo还有导出格式exe是32位还是64位

​ image-20260716233712720

点击convert,就能在这个ahk文件同目录找到这个exe文件

Window spy电脑屏幕参数监测

​ image-20261008093949979