Version 1a:
LCtrl & Esc::
ExitApp
return
You can add this code anywhere in your script. Press LCtrl and after Esc for script to exit.
Version 1b:
Esc & LCtrl::
ExitApp
return
You can add this code anywhere in your script. Press Esc and after LCtrl for script to exit.
You can add both Version 1a and Version 1b. In that case, when you press LCtrl and after Esc OR Esc and after LCtrl script will exit.
Version 2 (it uses different method, use it if for some reason you don't like Version 1a or/and Version 1b):
Loop
{
a := GetKeyState("Esc")
if (a=1)
{
b := GetKeyState("LCtrl")
if (b=1)
{
ExitApp
}
}
}
That code should be launch after your other code will remap all keys you need. Press LCtrl and after Esc OR Esc and after LCtrl for script to exit.
EDIT:
Version 3:
Loop
{
a := GetKeyState("Esc")
if (a=1)
{
Loop,60 ;number of 50 milliseconds script will wait to CTRL press. Example 60 means 60*50=3000, so script will wait 3000 milliseconds (1sec=1000 milliseconds) for CTRL press. After that time you have to press Esc again.
{
b := GetKeyState("LCtrl")
if (b=1)
{
ExitApp
}
Sleep, 50
}
}
}
That code should be launch after your other code will remap all keys you need. Press Esc (now you can release Esc ) and within 3000 milliseconds (1sec=1000 milliseconds) press LCtrl. After that time you have to press Esc again for script to exit. If you want to modify time after which you need to press Esc again read the comment in the code.
Also, always use AutoHotkey and its documenatation from http://ahkscript.org/ (current uptodate version, new official website)! AutoHotkey and its documentation from autohotkey.com is outdated and you may have some problems using them!
EndKeys
. Anyway, why don't you just use a native hotkey like^ESC
or^+ESC
? It's just as safe when it comes to accidental triggering of your routine and will save you lots of scripting trouble. – MCL