Sets a hotkey that calls a user function.
HotKeySet ( "key" [, "function"] )
Parameters
key | The key(s) to use as the hotkey. Same format as Send(). |
function | [optional] The name of the function to call when the key is pressed. Leave blank to unset a previous hotkey. |
Return Value
Success: | Returns 1. |
Failure: | Returns 0. |
Remarks
Up to 64 simultaneous hotkeys per script may be registered.Ctrl+Alt+Delete | It is reserved by Windows |
F12 | It is also reserved by Windows, according to its API. |
NumPad's Enter Key | Instead, use {Enter} which captures both Enter keys on the keyboard. |
Win+B,D,E,F,L,M,R,U; and Win+Shift+M | These are built-in Windows shortcuts. Note: Win+B and Win+L might only be reserved on Windows XP and above. |
Alt, Ctrl, Shift, Win | These are the modifier keys themselves! |
Other | Any global hotkeys a user has defined using third-party software, any combos of two or more "base keys" such as '{F1}{F2}', and any keys of the form '{LALT}' or '{ALTDOWN}'. |
Related
Send, ControlSend
Example
; Press Esc to terminate script, Pause/Break to "pause"
Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d
;;;; Body of program would go here ;;;;
While 1
Sleep(100)
WEnd
;;;;;;;;
Func TogglePause()
$Paused = NOT $Paused
While $Paused
sleep(100)
ToolTip('Script is "Paused"',0,0)
WEnd
ToolTip("")
EndFunc
Func Terminate()
Exit 0
EndFunc
Func ShowMessage()
MsgBox(4096,"","This is a message.")
EndFunc