找回密码
 加入
搜索
查看: 1607|回复: 11

请问如何退出这个循環

[复制链接]
发表于 2009-6-30 12:17:47 | 显示全部楼层 |阅读模式
本帖最后由 faceyao 于 2009-7-1 10:33 编辑

想要实现再次按下(即第二次按)"按钮1"的时候,就退出循环,请问代码该怎么改
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 492, 291, 232, 168)
$Button1 = GUICtrlCreateButton("Button1", 176, 72, 107, 41, $WS_GROUP)

GUISetState(@SW_SHOW)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                while 1
                        msgbox(0, "", "Hello World")
                Sleep(4000)
                WEnd

        EndSwitch
WEnd

本帖子中包含更多资源

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

×
发表于 2009-6-30 12:25:16 | 显示全部楼层
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 492, 291, 232, 168)
$Button1 = GUICtrlCreateButton("Button1", 176, 72, 107, 41, $WS_GROUP)

GUISetState(@SW_SHOW)
Dim $NUM=0
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                if $num = 0 then msgbox(0, "", "Hello World")
                 $num=1
                Sleep(4000)
                WEnd

        EndSwitch
WEnd
发表于 2009-6-30 12:28:13 | 显示全部楼层
我没试    你试试吧
 楼主| 发表于 2009-6-30 12:35:22 | 显示全部楼层
我没试    你试试吧
TheBelief 发表于 2009-6-30 12:28


谢谢,试了,但是运行报错,有2个wend
发表于 2009-6-30 12:42:13 | 显示全部楼层
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 492, 291, 232, 168)
$Button1 = GUICtrlCreateButton("Button1", 176, 72, 107, 41, $WS_GROUP)

GUISetState(@SW_SHOW)
Dim $NUM=0
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
               while 1
                if $num = 0 then msgbox(0, "", "Hello World")
                 $num=1
                Sleep(4000)
                WEnd

        EndSwitch
WEnd
发表于 2009-6-30 12:42:47 | 显示全部楼层
就是给你个思路   具体怎么实现自己整吧
发表于 2009-6-30 12:47:54 | 显示全部楼层
是我误删了一个  while 1  加上应该就没问题了
 楼主| 发表于 2009-6-30 12:55:24 | 显示全部楼层
是我误删了一个  while 1  加上应该就没问题了
TheBelief 发表于 2009-6-30 12:47


不行,这样一改循环功能没有了,第一次点这个按钮就不产生循环
发表于 2009-7-1 10:30:59 | 显示全部楼层
Case $Button1
                $T = 0
                while 1
                        if timerdiff($T) > 4000 then
                              $T = timerinit()
                              msgbox(0, "", "Hello World")
                        endif
                        if guigetmsg() = -3 then exit
                WEnd
发表于 2009-7-1 10:32:02 | 显示全部楼层
Case $Button1
                $T = 0
                while 1
                        if timerdiff($T) > 4000 then
                              $T = timerinit()
                              msgbox(0, "", "Hello World")
                        endif
                        if guigetmsg() = $Button1 then exit
                WEnd
发表于 2009-7-1 12:53:11 | 显示全部楼层
10# liongodmien

不错,高手就是高手,学到一招,谢谢。
 楼主| 发表于 2009-7-1 15:37:38 | 显示全部楼层
Case $Button1
                $T = 0
                while 1
                        if timerdiff($T) > 4000 then
                              $T = timerinit()
                              msgb ...
liongodmien 发表于 2009-7-1 10:32

运行错误
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-13 15:08 , Processed in 0.079836 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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