3131210 发表于 2017-5-23 08:32:20

[已解决]用了大神的HotKeyInput.au3和HotKey_21b.au3,不能GUICtrlSetData

本帖最后由 3131210 于 2017-5-23 15:31 编辑

下面是内容,我想用GUICtrlSetData设置热键,但是用GUICtrlSetData设置的热键,不能读出来,有没有解决办法?即使是控件内容已经改了,但是热键还是不会变

点击"设置热键",读不出热键代码#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
页: [1]
查看完整版本: [已解决]用了大神的HotKeyInput.au3和HotKey_21b.au3,不能GUICtrlSetData