How to package an AHK script as an EXE on Windows 10
Scripts are a lot like little programs; they run a series of commands and can accept input from a user. They’re mostly used to automate repetitive tasks. AutoHotKey scripts have a wide range of uses. From something basic like remapping keys to more complex operations like renaming and/or moving files and creating directories, the scripts are quite capable. They don’t stand in for batch scripts, but they have their own niche function and are popular on Windows.
Package AHK script as EXE
Convert .ahk to .exe with AutoHotKey
AutoHotKey scripts aren’t hard to run, and the app isn’t hard to install, but it might be easier to run them as an executable.
- Make sure AutoHotKey is installed on your system. Download it here.
- Open the Start Menu and go to the Apps list.
- Go to AutoHotKey in the Apps’ list, and select Convert .ahk to .exe.
- In the window that opens, click ‘Browse’ next to the ‘Source (script file)’ field.
- Click ‘Browse’ next to the ‘Destination (.exe file)’ and enter a name for the EXE file.
- Click Convert.
- The script will be converted within a few minutes.
The original script file will be untouched, and you will have a new EXE file.
AHK script as EXE – Command Line
You don’t have to use Convert .ahk to .exe to package an AHK script as an EXE. You can use the Command Line, but you do still need AutoHotKey installed.
- Open Command Prompt.
- Enter the following command to move to the compiler tool in the AutoHotKey installation folder.
cd C:\Program Files\AutoHotkey\Compiler
- Find the complete path to the AHK script.
- Enter the following command to convert the script and replace “MyScript.ahk” with the full path to the script.
Ahk2Exe.exe /in MyScript.ahk
Example
Ahk2Exe.exe /in "C:\Users\fatiw\Desktop\Test Script.ahk"
AutoHotKey has extensive documentation, and if you have trouble figuring things out, you can consult it here. You can modify the command and change the icon of the executable file that is generated.
In both the above methods, you’re using the built-in AutoHotKey conversion tool. The difference between them is how you’re using it to convert a script, i.e., via the GUI or the command-line.
Conclusion
Converting a script into an executable doesn’t make it more or less capable. An executable file is supported more widely; automation apps are more likely to be able to run an executable file than a script. AutoHotKey scripts are common, but they’re not as common as batch scripts or bash scripts, so they’re far less likely to be supported by automation apps.