I will state again that this is not particularly elegant, but it works for me.
;*** marks things you need to change for your environment
main script
Code:
;autoexecute section
Loop,
{
IfNotExist, TurnOff.exe
{
IfNotExist, TurnOn.exe
{
break ;don't start until the trigger files are deleted
}
}
sleep, 5000
}
SetTimer, UpdateAll, 30000 ;Run every N milliseconds
;your code can go here
Return
UpdateAll:
;Check for reloader
IfExist, TurnOff.exe
{
Run, TurnOff.exe
ExitApp
}
Return
TurnOff.ahk
Code:
;Instructions
;Compile TurnOff.ahk
;wait for ready message
;Compile main script.ahk
;Compile TurnOn.ahk
;wait a few seconds
;delete turnoff.exe
;*** put the name of your program here to notify users that the program is reloading
MsgBox, MAIN SCRIPT is being updated to a new version. It will start again automatically in 2-3 minutes.
Sleep, 60000
EnvGet, username, USERNAME
IfEqual, username, YOURUSERNAME ;*** put your user name here to be notified when all scripts should be closed
MsgBox, Try it now - compile the main script`nwait a few seconds`ncompile TurnOn`nwait a few seconds`ndelete Turnoff.exe`nwait a few seconds`ndelete Turnon.exe
;You can also cause TurnOff.exe to compile your main script, but I did not do this.
Loop,
;Check for reloader
{
IfExist, TurnOn.exe
{
Run, TurnOn.exe
ExitApp
}
Sleep, 5000
}
TurnOn.ahk
Code:
Run, main script.exe ;*** change to name of your compiled script
ExitApp