I have found a solution. This is not ideal (or ideal), and I hope that in the future the correct built-in method will be available, but it works well (enough) for raw and compiled scripts.
What I did was use the FileInstall command, which tells the compiler to add the file to the executable (and extract it when it starts).
Unfortunately, the FileInstall command FileInstall not allow the use of variables for the source file, so I canβt just include the script itself ( FileInstall, %A_ScriptFullPath%, %A_Temp%\%A_ScriptName%, 1 ).
As work, I ended up extracting all the desired hotkeys to the second file, which I then analyze as suggested by Elliot, then delete and #Include at the end of my script (it should be at the end, since the hotkeys will complete the autoexecute section).
;;;;; Test.ahk ;;;;; ; Add hotkey file to executable and extract to Temp directory at runtime FileInstall, Hotkeys.ahk, %A_Temp%\Hotkeys.ahk, 1 Loop { ;Read a line from the extracted hotkey script and quit if error FileReadLine, line, %A_Temp%\Hotkeys.ahk, %A_Index% if ErrorLevel break ;Trim whitespace line=%line% ; Parse the line as in Elliot's answer, but with tweaks as necessary ParseHotkey(line) β¦ } FileDelete, %A_Temp%\Hotkeys.ahk ; Delete the extracted script DisplayHotkeys() ; I ended up bulding and using a GUI instead #Include, Hotkeys.ahk ; It is included at compile-time, so no A_Temp ;;;;; Hotkeys.ahk ;;;;; z::MsgBox foo y::MsgBox bar
source share