The library allows to set hotkeys by using the low-level keyboard hook. Below are the main differences between HotKey UDF from the native HotKeySet() function:
- To assign a hotkeys are used integer values instead of strings as in the HotKeySet() function. This is useful, for example, to save the hotkey's values in the registry.
- Ability to set any hotkeys including CTRL+ALT+DEL, F12, WIN+*, etc. The only exceptions are special keys such as "Fn" which do not have their own scan code.
- Ability to utilize or pass on the specified hotkeys for other applications.
- Ability to set hotkeys that already used by other applications.
- Ability to set hotkeys only for the specified window(s).
- Ability to prevent re-activation of the hotkeys when it is held down.
- Ability to disable previously installed hotkeys without removing the hook from the hook chain, ie without losing priority.
- Ability to block call user-defined function associated with the hotkey if the previous call has not been completed.
- Set hotkey only for the CTRL, ALT, SHIFT, WIN, and any combination of this keys. Any hotkey should always include one function key. For example, ALT+A, CTRL+SHIFT+F10, etc.
- Set hotkey for a mouse buttons.
- Prevent using the hotkey like CTRL+ALT+DEL, CTRL+SHIFT+ESC (Windows Vista+), and similar.
- Use more than one function key in the hotkey. For example, ALT+A+B, F1+F2, etc.
- Use "Fn" key or any other keys that do not have their own scan code.
HotKey UDF Library v1.8
Previous downloads: 5027
HotKey.au3 26.37KB 672 downloads
HotKey UDF Library v2.1b (Read here for more information)
Previous downloads: 1791
HotKey_21b.au3 26.98KB 409 downloads
Virtual-Key (VK) Code Constants (Optional)
Previous downloads: 1576
vkConstants.au3 5.62KB 1993 downloads
#Include <HotKey.au3> Global Const $VK_ESCAPE = 0x1B Global Const $VK_F12 = 0x7B ; Assign "F12" with Message() and set extended function call _HotKey_Assign($VK_F12, 'Message', BitOR($HK_FLAG_DEFAULT, $HK_FLAG_EXTENDEDCALL)) ; Assign "CTRL-ESC" with Quit() _HotKey_Assign(BitOR($CK_CONTROL, $VK_ESCAPE), 'Quit') While 1 Sleep(10) WEnd Func Message($iKey) MsgBox(0, 'Hot key Test Message', 'F12 (0x' & Hex($iKey, 4) & ') has been pressed!') EndFunc ;==>Message Func Quit() Exit EndFunc ;==>Quit
#Include <HotKey.au3> Global Const $VK_OEM_PLUS = 0xBB Global Const $VK_OEM_MINUS = 0xBD Global $Form, $Label Global $i = 0 $Form = GUICreate('MyGUI', 200, 200) $Label = GUICtrlCreateLabel($i, 20, 72, 160, 52, 0x01) GUICtrlSetFont(-1, 32, 400, 0, 'Tahoma') GUISetState() ; Assign "CTRL-(+)" with MyFunc1() and "CTRL-(-)" with MyFunc2() for created window only _HotKey_Assign(BitOR($CK_CONTROL, $VK_OEM_PLUS), 'MyFunc1', 0, $Form) _HotKey_Assign(BitOR($CK_CONTROL, $VK_OEM_MINUS), 'MyFunc2', 0, $Form) Do Until GUIGetMsg() = -3 Func MyFunc1() $i += 1 GUICtrlSetData($Label, $i) EndFunc ;==>MyFunc1 Func MyFunc2() $i -= 1 GUICtrlSetData($Label, $i) EndFunc ;==>MyFunc2
Edited by Yashied, 06 February 2014 - 06:05 PM.