如何退
本帖最后由 faceyao 于 2009-8-24 22:50 编辑如图,点了那个确定后,是一个循环。#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("对话框", 316, 232, 307, 261)
GUISetIcon("D:\003.ico")
$GroupBox1 = GUICtrlCreateGroup("", 8, 1, 297, 193)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("确定(&O)", 65, 203, 75, 25, 0)
$Button2 = GUICtrlCreateButton("退出(&C)", 162, 203, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $button1
while1
.......
wend
Case $button2
exit
EndSwitch
WEnd以上,点右边的取消却退出不了,目的是要“点取消就退出循环或关闭整个软件” ExitLoop
~~~~~~~~~~~~~~~~~~~~~~~ ExitLoop
~~~~~~~~~~~~~~~~~~~~~~~
破帽遮颜 发表于 2009-8-24 21:23 http://www.autoitx.com/images/common/back.gif
exitloop,exit,甚至winkill我都用了,不行啊,都失败了,就是无法退出 本帖最后由 netegg 于 2009-8-24 21:50 编辑
中间是什么代码,我试了可以退呀
明白了,你是说先点确定然后点取消是吗
用coproc 楼上,是的,先点确定然后点取消无效(点取消却取消不了,也就是终止不了) 没用的!循环内镶嵌死循环,这au3是单线程,怎么响应呢
换个方式吧 这段代码和楼主的比较相似,关键就看你的循环是怎样的,希望能给你启发。
#Include <Date.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Dim $i
$Form1 = GUICreate("计时+时间循环", 300, 200, -1, -1)
$Button1 = GUICtrlCreateButton("开始", 40, 60, 100, 30, 0)
$Button2 = GUICtrlCreateButton("停止", 160, 60, 100, 30, 0)
$Label1 = GUICtrlCreateLabel("准备就绪", 58, 130, 180, 50, $SS_CENTER)
GUICtrlSetFont(-1, 15, 800, 0, "楷体_GB2312")
$Label2 = GUICtrlCreateLabel(_now(),180,180)
$Label3 = GUICtrlCreateLabel("当前系统时间:", 105, 180)
GUISetState(@SW_SHOW)
While 1
$OLDT=GUICtrlRead($Label2)
$NEWT=_now()
If $NEWT<>$OLDT Then GUICtrlSetData($Label2,$NEWT)
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Button1
$a = GUICtrlRead($Button1)
If $a = "开始" Then
$i = 0
AdlibEnable('cont', 1000)
Else
AdlibEnable('cont', 1000)
EndIf
Case $Button2
AdlibDisable()
GUICtrlSetData($Label1,"暂停至"&$i&"秒")
GUICtrlSetData($Button1,"继续")
EndSwitch
WEnd
Func cont()
$i += 1
GUICtrlSetData($Label1,"已开始"&$i&"秒")
EndFunc
本帖最后由 baikaifang 于 2009-8-24 23:57 编辑
这个问题好处理,下面是我常用的方法,有兴趣的可以看看。
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("对话框", 316, 232, 307, 261)
$GroupBox1 = GUICtrlCreateGroup("", 8, 1, 297, 193)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("开始(&O)", 65, 203, 75, 25, 0)
$Button2 = GUICtrlCreateButton("退出(&C)", 162, 203, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE, $Button2
Exit
Case $Button1
GUICtrlSetData($Button1, "循环中...")
GUICtrlSetData($Button2, "停止")
While 1
If GUIGetMsg() = $Button2 Then
GUICtrlSetData($Button1, "开始(&O)")
GUICtrlSetData($Button2, "退出(&C)")
ExitLoop
EndIf
WEnd
EndSwitch
WEnd
楼上的代码经典
页:
[1]