HotKeySet

From AutoIt Wiki

Jump to: navigation, search

Allows you to set a keyboard key to call a function. Adapted from AutoIt docs.

Contents

[edit] Syntax

HotKeySet("key" [, "function"])

[edit] Parameters

ParamDescription
keyThe 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+DelWindows reserved.
F12Windows reserved.
NumPad EnterUse {ENTER}.
Win+B,D,E,F,L,M,R,U; and Win+Shift+MBuilt in Windows shortcuts.
Alt, Ctrl, Shift, WinModifier keys. Includes {LALT},{SHIFTDOWN}, etc.
OtherAny 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

[edit] Related Functions

Send ControlSend

Personal tools