Enable and disable an hotkey in AutoIt

Send Us a Sign! (Contact Us!)

To enable and/or disable a specified hotkey in AutoIt code we need to "not-specify" any function associated with it. We can understand more easily this concept by reviewing the following example (only function):

Func _EnableDisable()

If $hotkeys=0 Then ;Hotkeys are disabled so we enable them
HotKeySet("E","_Ekey")
$hotkeys=1 ;We know now Hotkeys are enabled
Else
HotKeySet("E") ;Disable HotKey "E"
$hotkeys=0 ;We know now Hotkeys are disabled
EndIf
EndFunc

Func _Ekey()
MsgBox(0,"","_Ekey activated")
EndFunc

So, to completely disable an hotkey set with HotKeySet function we need to NOT specify, always with HotKeySet function, the same key (previously used to call the final function) without any associated function:

HotKeySet("E","_Ekey") --> HotKeySet("E")