关于 设置热键问题
#Region ;**** 参数创建于 ACNWrapper_GUI ****#AutoIt3Wrapper_icon=
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_UseX64=y
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
;#NoTrayIcon
#include <GUIConstantsEx.au3>
#Include <ACN_MISC.au3>
#include <Array.au3>
#Include <File.au3>
#include <Array.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)
Global $msg,$input1,$combo1,$combo2,$checkbox1,$flag,$num,$hot_key,$toggle = 0
test()
Func test()
HotKeySet("{F8}","toggle")
;HotKeySet("{"&hot_key&"}","toggle") ;想实现自定义热键的功能
GUICreate("test",370,267)
GUISetBkColor (0x00ffffff)
GUICtrlSetDefColor(0x000000);设置文本默认颜色
GuiCtrlCreateLabel ( "请选择好频率:",20, 20, 100, 21,0x0300)
$combo1=GUICtrlCreateCombo("", 110, 20,60,21)
GUICtrlSetData(-1, "10|100|1000","100")
GuiCtrlCreateLabel ( "开始执行的热键设置:",20, 80, 120, 21,0x0300)
$combo2=GUICtrlCreateCombo("", 140, 80,60,21)
GUICtrlSetData(-1, "F2|F3|F4|F5|F6|F7|F8","F8")
GuiCtrlCreateLabel ( "键",205, 80, 120, 21,0x0300)
$checkbox1=GUICtrlCreateCheckbox("", 20, 50, 20, 20)
GuiCtrlCreateLabel ( "输入自定义的频率为:",41, 50, 180, 21,0x0300)
$input1=GUICtrlCreateInput("50", 160, 50, 50, 20)
GuiCtrlCreateLabel ( "次",205, 50, 20, 21,0x0300)
GUICtrlSetColor(-1, 0x000000)
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
ExitLoop
Case $checkbox1
$hot_key=GUICtrlRead($combo2)
MsgBox("","",GUICtrlRead($checkbox1,1))
If BitAND(GUICtrlRead($checkbox1),$GUI_CHECKED) Then
GUICtrlSetState($combo1,$GUI_DISABLE)
$num=Number(GUICtrlRead($input1))
Else
GUICtrlSetState($combo1,$GUI_ENABLE)
GUICtrlRead($combo2)
EndIf
EndSwitch
WEnd
EndFunc
Func start()
While 1
While $toggle
MouseClick("left")
WEnd
WEnd
EndFunc
Func toggle()
$toggle = Not $toggle ;not 实现开关功能
If $toggle=1 Then
start()
EndIf
EndFunc
现在问题是我用设置的f8快捷键进行操作时,发现程序执行时,再按f8暂停后,点关闭按钮,关不了窗口,第2个问题,我用变量hot_key想获得组合框中的自定义热键HotKeySet("{F8}","toggle")(,但是按照选择的热键,发现不能执行,放在低码偏下位置也不能执行。不知道什么原因,hotkey的代码放哪好。 Func start()
If $toggle Then
MouseClick("left")
Else
AdlibRegister('start')
EndIf
WEnd
EndFunc
Func toggle()
$toggle = Not $toggle ;not 实现开关功能
If $toggle Then AdlibRegister('start', 100)
EndFunc 原来START函数,一执行就是个死循环. 放在脚本的开始。 怎么提示AdlibRegister 没有定义,要包含什么文件吗,这个AdlibRegister在帮助里居然没有,是不是AdlibEnable 回复 5# zlmyongheng
你用版本太落后了.
好多年前,此函数就已改名了. 一直不知道这个函数,什么情况下用,帮助也写得太简单了。 把这一句:HotKeySet("{F8}","toggle")
换成下面的一句,发现不执行,按热键没反应,不能实现自定义热键功能
HotKeySet("{"&hot_key&"}","toggle") ;想实现自定义热键的功能 有人知道帮一下,实在不知道为什么自定义热键功能没办法用,改了好几次 $hot_key变量的位置 问题,已经解决了,但还是感觉,解决的方法不够完美 修改后的自定义热键可以执行了,留下给需要的人
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_UseX64=y
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
;#NoTrayIcon
#include <GUIConstantsEx.au3>
#Include <ACN_MISC.au3>
#include <Array.au3>
#Include <File.au3>
#include <Array.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)
Global $msg,$input1,$combo1,$combo2,$checkbox1,$flag,$num,$hot_key,$toggle = 0,$frequency
test()
Func test()
;HotKeySet("{F8}","toggle")
GUICreate("test",370,267)
GUISetBkColor (0x00ffffff)
GUICtrlSetDefColor(0x000000);设置文本默认颜色
GuiCtrlCreateLabel ( "请选择好频率:",20, 20, 100, 21,0x0300)
$combo1=GUICtrlCreateCombo("", 110, 20,60,21)
GUICtrlSetData(-1, "10|100|1000","100")
GuiCtrlCreateLabel ( "开始执行的热键设置:",20, 80, 120, 21,0x0300)
$combo2=GUICtrlCreateCombo("", 140, 80,60,21)
GUICtrlSetData(-1, "F2|F3|F4|F5|F6|F7|F8","F8")
GuiCtrlCreateLabel ( "键",205, 80, 120, 21,0x0300)
$checkbox1=GUICtrlCreateCheckbox("", 20, 50, 20, 20)
GuiCtrlCreateLabel ( "输入自定义的频率为:",41, 50, 180, 21,0x0300)
$input1=GUICtrlCreateInput("50", 160, 50, 50, 20)
GuiCtrlCreateLabel ( "次",205, 50, 20, 21,0x0300)
GUICtrlSetColor(-1, 0x000000)
GUISetState()
$hot_key=GUICtrlRead($combo2)
;MsgBox("","",$hot_key)
HotKeySet("{"&$hot_key&"}","toggle")
While 1
$msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
ExitLoop
Case $checkbox1
MsgBox("","",GUICtrlRead($checkbox1,1))
If BitAND(GUICtrlRead($checkbox1),$GUI_CHECKED) Then
GUICtrlSetState($combo1,$GUI_DISABLE)
$num=Number(GUICtrlRead($input1))
Else
GUICtrlSetState($combo1,$GUI_ENABLE)
EndIf
case $combo2
$hot_key=GUICtrlRead($combo2)
HotKeySet("{"&$hot_key&"}","toggle")
EndSwitch
WEnd
EndFunc
Func start()
if $toggle Then
;MouseClick("left")
check()
AdlibEnable('start')
EndIf
EndFunc
Func toggle()
$toggle = Not $toggle ;not 实现开关功能
If $toggle Then AdlibEnable('start', 100)
EndFunc
HotKeySet("{F8}","toggle")
Func check()
$frequency=10
If $frequency>=1 Then
while $frequency>0
MsgBox(16,"",$frequency)
$frequency=$frequency-1
WEnd
EndIf
EndFunc 更新一下版本
页:
[1]