找回密码
 加入
搜索
查看: 1389|回复: 0

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

[复制链接]
发表于 2017-5-23 08:32:20 | 显示全部楼层 |阅读模式
本帖最后由 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

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-20 02:45 , Processed in 0.088711 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表