HotKeySet
From AutoIt Wiki
Allows you to set a keyboard key to call a function. Adapted from AutoIt docs.
Contents |
[edit] Syntax
HotKeySet("key" [, "function"])
[edit] Parameters
| Param | Description |
|---|---|
| key | The key combination to call the function. |
| function | (Optional). The name of the function to be called upon key signature. Not specifying this field will reset the key. |
[edit] Keys
The key field will only recognize the first character/modified character placed in the key field. For example
HotKeySet("abc","HelloWorld")
will only fire on a.
See Send() for special key definitions.
It should be noted that there exists a set of keys that cannot be acted upon due to the Windows environment.
| Key(s) | Reason |
|---|---|
| Ctrl+Alt+Del | Windows reserved. |
| F12 | Windows reserved. |
| NumPad Enter | Use {ENTER}. |
| Win+B,D,E,F,L,M,R,U; and Win+Shift+M | Built in Windows shortcuts. |
| Alt, Ctrl, Shift, Win | Modifier keys. Includes {LALT},{SHIFTDOWN}, etc. |
| Other | Any global hotkey defined by third-party software. |
[edit] Function
[edit] Return Value
Success: Returns 1.
Failure: Returns 0.
[edit] Example
; helloWorld() will execute and exit program on Alt+Tab press
Func helloWorld()
MsgBox(0,"","Hello World!")
Exit 0
EndFunc
HotKeySet("!{TAB}","helloWorld"); assign Alt+Tab
; Dummy loop for listening.
While 1
Sleep(100); program body here
WEnd
