如何让热键执行的循环,退出来
#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()
GUICreate("test",370,267)
GUISetBkColor (0x00ffffff)
GUICtrlSetDefColor(0x000000);设置文本默认颜色
GuiCtrlCreateLabel ( "请选择好频率:",20, 20, 100, 21,0x0300)
$combo1=GUICtrlCreateCombo("", 110, 20,60,21)
GUICtrlSetData(-1, "5|10","5")
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("4", 160, 50, 50, 20)
GuiCtrlCreateLabel ( "次",205, 50, 20, 21,0x0300)
GUICtrlSetColor(-1, 0x000000)
GUISetState()
$hot_key=GUICtrlRead($combo2)
HotKeySet("{"&$hot_key&"}","toggle")
While 1
$msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
ExitLoop
Case $checkbox1
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
If BitAND(GUICtrlRead($checkbox1),$GUI_CHECKED) Then
$num=Number(GUICtrlRead($input1))
Else
$num=Number(GUICtrlRead($combo1))
EndIf
EndFunc
Func start()
if $toggle Then
check($num)
AdlibEnable('start')
EndIf
EndFunc
Func toggle()
$toggle = Not $toggle
If $toggle Then AdlibEnable('start', 100)
EndFunc
Func check($x)
while $x>0
MsgBox(16,"",$x)
$x=$x-1
if $x=0 Thenexit ;想退出程序的执行,返回主界面,而不是退出程序
WEnd
EndFunc
请看一下我注释的那一句,我想程序执行指定的次数,然后退出来,结果当循环到0的时候我用exit 直接退出了整个界面,我要的效果是退出到主界面,我试过把exit换成exitloop,结果还是停不下来。简单的说就是当循环次数达到,中断执行,返回主界面,便于执行其它的设置。也搜索过,帮助也看过,无从找起。 代码要整理好,并用标签发帖
问题不少,意思不明,AU3版本函数老旧,粗看粗修
#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 = 5, $hot_key, $toggle = 0, $frequency
test()
Func test()
GUICreate("test", 370, 267)
GUISetBkColor(0x00ffffff)
GUICtrlSetDefColor(0x000000);设置文本默认颜色
GUICtrlCreateLabel("请选择好频率:", 20, 20, 100, 21, 0x0300)
$combo1 = GUICtrlCreateCombo("", 110, 20, 60, 21)
GUICtrlSetData(-1, "5|10", $num)
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("4", 160, 50, 50, 20)
GUICtrlCreateLabel("次", 205, 50, 20, 21, 0x0300)
GUICtrlSetColor(-1, 0x000000)
GUISetState()
$hot_key = GUICtrlRead($combo2)
HotKeySet("{" & $hot_key & "}", "toggle")
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
ExitLoop
Case $checkbox1
If BitAND(GUICtrlRead($checkbox1), $GUI_CHECKED) Then
GUICtrlSetState($combo1, $GUI_DISABLE)
$num = Number(GUICtrlRead($input1))
Else
GUICtrlSetState($combo1, $GUI_ENABLE)
$num = Number(GUICtrlRead($combo1))
EndIf
Case $combo2
$hot_key = GUICtrlRead($combo2)
HotKeySet("{" & $hot_key & "}", "toggle")
EndSwitch
WEnd
;~ If BitAND(GUICtrlRead($checkbox1), $GUI_CHECKED) Then
;~ $num = Number(GUICtrlRead($input1))
;~ Else
;~ $num = Number(GUICtrlRead($combo1))
;~ EndIf
EndFunc ;==>test
Func start()
If $toggle Then
check($num)
;~ AdlibEnable('start')
EndIf
EndFunc ;==>start
Func toggle()
$toggle = Not $toggle
;~ If $toggle Then AdlibEnable('start', 100)
If $toggle Then AdlibRegister('start', 100)
EndFunc ;==>toggle
Func check($x)
While $x > 0
MsgBox(16, "", $x)
$x = $x - 1
If $x = 0 Or Not $toggle Then ;Exit ;想退出程序的执行,返回主界面,而不是退出程序
;~ AdlibDisable()
AdlibUnRegister()
$toggle = 0
Return
EndIf
WEnd
EndFunc ;==>check 谢谢,我发现对这个AdlibRegister或AdlibDisable()不太理解,帮助太简单了,网上也搜索只告诉你事例不知道为什么要加上这个就正常了,当时也试了一下,没成功。现在autoit最新好用的版本是哪种,版本多太乱了
页:
[1]