请问如何退出这个循環
本帖最后由 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
#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 我没试 你试试吧 我没试 你试试吧
TheBelief 发表于 2009-6-30 12:28 http://www.autoitx.com/images/common/back.gif
谢谢,试了,但是运行报错,有2个wend #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 就是给你个思路 具体怎么实现自己整吧 是我误删了一个while 1加上应该就没问题了 是我误删了一个while 1加上应该就没问题了
TheBelief 发表于 2009-6-30 12:47 http://www.autoitx.com/images/common/back.gif
不行,这样一改循环功能没有了,第一次点这个按钮就不产生循环 Case $Button1
$T = 0
while 1
if timerdiff($T) > 4000 then
$T = timerinit()
msgbox(0, "", "Hello World")
endif
if guigetmsg() = -3 then exit
WEnd Case $Button1
$T = 0
while 1
if timerdiff($T) > 4000 then
$T = timerinit()
msgbox(0, "", "Hello World")
endif
if guigetmsg() = $Button1 then exit
WEnd 10# liongodmien
不错,高手就是高手,学到一招,谢谢。 Case $Button1
$T = 0
while 1
if timerdiff($T) > 4000 then
$T = timerinit()
msgb ...
liongodmien 发表于 2009-7-1 10:32 http://www.autoitx.com/images/common/back.gif
运行错误
页:
[1]