在循环体内用Opt("GUIOnEventMode", 0)#include <GUIConstantsEx.au3>
Opt("GUIOnEventMode", 1)
GUICreate("form1",200,100)
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
Local $start=GUICtrlCreateButton("开始",10,30,180,20)
GUICtrlSetOnEvent($start,"_While1")
Local $stop=GUICtrlCreateButton("中止",10,50,180,20)
GUICtrlSetOnEvent($stop, "_exit")
GUISetState (@SW_SHOW)
While 1
Sleep(1000)
WEnd
Func _exit ()
MsgBox (0,"","退出")
Exit
EndFunc
Func _While1()
opt ("GUIOnEventMode",0)
while 1
Sleep(100)
$msg = GUIGetMsg()
Switch $msg
Case $stop
_exit ()
EndSwitch
WEnd
EndFunc
|