#include <GUIConstantsEx.au3>
#include <HotKeyInput.au3>
#include <HotKey_21b.au3>
Global $Form, $HKI1, $HKI2, $Button, $Text, $Label
Global $i = 0
$Form = GUICreate('Test', 300, 560)
GUISetFont(8.5, 400, 0, 'Tahoma', $Form)
$Label = GUICtrlCreateLabel($i, 20, 300, 160, 52, 0x01)
GUICtrlSetFont(-1, 32, 400, 0, 'Tahoma')
$HKI1 = _GUICtrlHKI_Create(0, 56, 55, 230, 20)
$HKI2 = _GUICtrlHKI_Create(0, 56, 89, 230, 20)
; Lock CTRL-ALT-DEL for Hotkey Input control, but not for Windows
_KeyLock(0x062E)
GUICtrlCreateLabel('Hotkey1:', 10, 58, 44, 14)
GUICtrlCreateLabel('Hotkey2:', 10, 92, 44, 14)
GUICtrlCreateLabel('Click on Input box and hold a combination of keys.' & @CR & 'Press OK to view the code.', 10, 10, 280, 28)
$Button = GUICtrlCreateButton('OK', 110, 124, 80, 23)
$Button2 = GUICtrlCreateButton('设置热键', 110, 164, 80, 23)
GUICtrlSetState(-1, BitOR($GUI_DEFBUTTON, $GUI_FOCUS))
GUISetState()
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $Button
$Text = 'Hotkey1: 0x' & StringRight(Hex(_GUICtrlHKI_GetHotKey($HKI1)), 4) & ' (' & GUICtrlRead($HKI1) & ')' & @CR & @CR & _
'Hotkey2: 0x' & StringRight(Hex(_GUICtrlHKI_GetHotKey($HKI2)), 4) & ' (' & GUICtrlRead($HKI2) & ')'
MsgBox(0, 'Code', $Text, 0, $Form)
_HotKey_Assign(_GUICtrlHKI_GetHotKey($HKI1), 'MyFunc1', 0)
_HotKey_Assign(_GUICtrlHKI_GetHotKey($HKI2), 'MyFunc2', 0)
Case $Button2
GUICtrlSetData($HKI1, '+')
GUICtrlSetData($HKI2, '-')
$Text = 'Hotkey1: 0x' & StringRight(Hex(_GUICtrlHKI_GetHotKey($HKI1)), 4) & ' (' & GUICtrlRead($HKI1) & ')' & @CR & @CR & _
'Hotkey2: 0x' & StringRight(Hex(_GUICtrlHKI_GetHotKey($HKI2)), 4) & ' (' & GUICtrlRead($HKI2) & ')'
MsgBox(0, 'Code', $Text, 0, $Form)
_HotKey_Assign(_GUICtrlHKI_GetHotKey($HKI1), 'MyFunc1', 0)
_HotKey_Assign(_GUICtrlHKI_GetHotKey($HKI2), 'MyFunc2', 0)
EndSwitch
WEnd
Func MyFunc1()
$i += 1
GUICtrlSetData($Label, $i)
EndFunc ;==>MyFunc1
Func MyFunc2()
$i -= 1
GUICtrlSetData($Label, $i)
EndFunc ;==>MyFunc2