Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #SingleInstance force
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- EXECUTABLE_PATH=
- EXECUTABLE_NAME=
- EXECUTABLE_TIMEOUTMSG=
- ; Config file is the script name with .ini instead of .ahk or .exe
- SplitPath, A_ScriptName,,,, ConfigFile
- ConfigFile := ConfigFile . ".ini"
- gConfigIsNew := false
- if (!FileExist(ConfigFile))
- gConfigIsNew := true
- IniReadWrite(file, category, key, defaultValue) {
- IniRead, output, %file%, %category%, %key%
- if (output = "ERROR" or !output) {
- IniWrite, %defaultValue%, %file%, %category%, %key%
- output := defaultValue
- }
- return output
- }
- ;---------------------------------------------;
- ; Read config options from the INI file here. ;
- ;---------------------------------------------;
- ;---------------------------------------------;
- ; Open the INI file to be edited by the user, if this is the first time the script has been run
- if (gConfigIsNew)
- Run, %ConfigFile%
- Process, Exist, %EXECUTABLE_NAME%
- if (!ErrorLevel) { ; if the executable isn't already running
- Run, %EXECUTABLE_PATH% ; launch the executable
- loop {
- Process, Wait, %EXECUTABLE_NAME%, 120 ; wait for it to load
- if (ErrorLevel) ; if the executable is running
- break ; break loop
- ; If it took more than two minutes, ask the user if they wish to continue waiting
- MsgBox, 0x40034, Timed Out, %EXECUTABLE_TIMEOUTMSG% Continue waiting?
- IfMsgBox No
- ExitApp
- }
- }
- Hotkey, IfWinActive, ahk_exe %EXECUTABLE_NAME%
- ;-----------------------------------------;
- ; Place dynamically created hotkeys here. ;
- ;-----------------------------------------;
- ;-----------------------------------------;
- Hotkey, IfWinActive
- ;-------------------------------;
- ; Place auto-execute code here. ;
- ;-------------------------------;
- ;-------------------------------;
- Process, WaitClose, %EXECUTABLE_NAME% ; wait for the executable to close
- ExitApp ; then exit app
- ;------------------------------------;
- ; Place hotkeys and other code here. ;
- ;------------------------------------;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement