If, like me, you sometimes need to quit then re-launch (rather than simply reload) AHK, you can put something like this in the autoexec section of your main script. The example code allows the use of "ctrl+alt+q" to launch your main script file even without AHK already running. (And if you have an AHK-defined hotkey to quit the script, you can reuse the same hotkey for launching the script, so the overall effect of the hotkey is to toggle the running/not-running status of the script itself)
Code: Select all
CreateShortcutToScript("q")
CreateShortcutToScript(ShortcutKey){
ShortcutPath := A_StartMenuCommon "\" A_ScriptName ".lnk"
if !FileExist(ShortcutPath)
FileCreateShortcut(A_AhkPath, ShortcutPath, A_WorkingDir, '"' . A_ScriptFullPath '"',,,ShortcutKey,,)
}
^!q::ExitApp()