I have this script:
Code: Select all
RegWrite, REG_SZ, HKEY_CURRENT_USER\Keyboard Layout\Toggle, Hotkey, 3
RegWrite, REG_SZ, HKEY_CURRENT_USER\Keyboard Layout\Toggle, Language Hotkey, 3
#IfWinActive, ahk_exe game.exe
SetTimer process_watcher, 100
process_watcher:
Process Exist, game.exe
If ErrorLevel = 0
Exitapp
Return
a) Writes (changes) existing registry keys that disable the Alt+Shift language toggle hotkey of MS Windows.
b) Checks if a certain program is running, and if not, it exits the script.
How can I restore the values, just before exiting, and only if the automatic exit is triggered?
Code: Select all
RegWrite, REG_SZ, HKEY_CURRENT_USER\Keyboard Layout\Toggle, Hotkey, 1
RegWrite, REG_SZ, HKEY_CURRENT_USER\Keyboard Layout\Toggle, Language Hotkey, 1