本帖最后由 easefull 于 2011-4-18 03:34 编辑
事件模式的解决方案
作者:风行者
来源:http://www.autoitx.com/forum.php ... amp;fromuid=7652895#include <GUIConstantsEx.au3>
Opt("GUIOnEventMode",1)
$Form1 = GUICreate("游戏", 351, 271, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE,"close")
$Label1 = GUICtrlCreateLabel("---", 32, 64, 80, 20)
$Button1 = GUICtrlCreateButton("开始", 112, 16, 43, 25)
GUICtrlSetOnEvent(-1,"button1")
$Button4 = GUICtrlCreateButton("停止", 180, 16, 43, 25)
GUICtrlSetOnEvent(-1,"button4")
GUISetState(@SW_SHOW)
Global $i = False
While 1
Local $new
If $i = True Then
$new = $new + Random(-10,10,1)
GUICtrlSetData($Label1,$new)
EndIf
Sleep(1000)
WEnd
GUIDelete()
Func close()
Exit
EndFunc
Func button1()
$i = True
EndFunc
Func button4()
$i = False
EndFunc
|