Hotkey to restart autohotkey script?

Make a hotkey that runs a script, which in this case is the same script and then exit.

somehotkey::
    Run, C:\path\to\my\script.ahk
    ExitApp
return

In order to prevent duplicate instances, I normally do not re-launch a script but use the build-in function Reload. I launch this with Ctrl+Win+Alt+R and use Ctrl+Win+Alt+E to edit the main AHK script.

^#!r::Reload

Actually, my script looks like this:

^#!r::
Send, ^s ; To save a changed script
Sleep, 300 ; give it time to save the script
Reload
Return

^!#e::Edit

As a matter of fact, all the way at the top of my script I have this to give me a visual and audio indication that the script was restarted:

#SingleInstance Force
#installKeybdHook
#Persistent
Menu, Tray, Icon , Shell32.dll, 25, 1
TrayTip, AutoHotKey, Started, 1
SoundBeep, 300, 150
Return

Tags:

Autohotkey