找回密码
 加入
搜索
查看: 1290|回复: 8

如何退

[复制链接]
发表于 2009-8-24 21:18:08 | 显示全部楼层 |阅读模式
本帖最后由 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
                                                while  1
                                                  .......

                                                 wend
                                  Case $button2

                                        exit

        EndSwitch
WEnd
以上,点右边的取消却退出不了,目的是要“点取消就退出循环或关闭整个软件”

本帖子中包含更多资源

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

×
发表于 2009-8-24 21:23:11 | 显示全部楼层
ExitLoop
~~~~~~~~~~~~~~~~~~~~~~~
 楼主| 发表于 2009-8-24 21:36:43 | 显示全部楼层
ExitLoop
~~~~~~~~~~~~~~~~~~~~~~~
破帽遮颜 发表于 2009-8-24 21:23


exitloop,exit,甚至winkill我都用了,不行啊,都失败了,就是无法退出
发表于 2009-8-24 21:46:59 | 显示全部楼层
本帖最后由 netegg 于 2009-8-24 21:50 编辑

中间是什么代码,我试了可以退呀
明白了,你是说先点确定然后点取消是吗
用coproc
 楼主| 发表于 2009-8-24 21:51:15 | 显示全部楼层
楼上,是的,先点确定然后点取消无效(点取消却取消不了,也就是终止不了)
发表于 2009-8-24 23:04:29 | 显示全部楼层
没用的!循环内镶嵌死循环,这au3是单线程,怎么响应呢
换个方式吧
发表于 2009-8-24 23:32:19 | 显示全部楼层
这段代码和楼主的比较相似,关键就看你的循环是怎样的,希望能给你启发。
#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
发表于 2009-8-24 23:53:33 | 显示全部楼层
本帖最后由 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
发表于 2009-8-25 16:03:26 | 显示全部楼层
楼上的代码经典
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-7 18:33 , Processed in 0.075996 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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