In case anyone else needs this. Note the 4 second pause is because gamex crashes while entering sleep mode and we want it to restart after sleep mode is over. I couldn't find any way in autohotkey to detect exiting sleep mode. You will want to clear all your desktop icons and set a plain wallpaper as you will be looking at your desktop a couple seconds before it restarts. However I found when I set the toolbar to autohide in vista, starting gamex from the start menu seems to start it up minimized. Another script for another day I guess. The 10 second pause after is so if you get a repeating error on startup you don't get the gamex error box wildly popping up over and over. loop { IfWinExist GameEx Error { WinActivate } else { WinWait GameEx Error WinActivate } WinClose SoundBeep sleep, 4000 runwait "C:\Program Files\GameEx\GameEx.exe" sleep, 10000 }