本帖最后由 chnlikang 于 2010-5-19 18:45 编辑
回复 7# netegg
看这个例子是我提的问题所在#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("例子", 258, 123, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Button1 = GUICtrlCreateButton("开始演示", 24, 40, 75, 25)
GUICtrlSetOnEvent(-1, "Button1Click")
$Button2 = GUICtrlCreateButton("停止演示", 152, 40, 75, 25)
GUICtrlSetOnEvent(-1, "Button2Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $a=0
While 1
Select
Case $a=1
While 1
If $a=2 Then ExitLoop
Sleep(500)
MsgBox(0,"","现在请你按停止键")
Sleep(500)
MsgBox(0,"","是不是还没有停止呀")
Sleep(500)
MsgBox(0,"","循环中的msgbox共有7个,这是第3个")
Sleep(500)
MsgBox(0,"","$a在点击停止按钮后就=2了,但是后面的代码还在运行。")
Sleep(500)
MsgBox(0,"","这是第5个msgbox,当$a=2时循环是停止了,但不是立刻退出")
Sleep(500)
MsgBox(0,"","直到运行到第7个MSGBOX,才退出,这是第6个")
Sleep(500)
MsgBox(0,"","这是第7个, 循环代码退出。但并不是程序不退出,不是EXIT的效果")
Sleep(500)
WEnd
Case $a=2
$a=0
MsgBox(0,"","循环终于停止啦")
EndSelect
WEnd
Func Button1Click()
$a=1
EndFunc
Func Button2Click()
$a=2
EndFunc
Func Form1Close()
MsgBox(0,"","不只我匆匆写下这个例子,你可明白我提问的问题")
Exit
EndFunc
|