比较喜欢事件模式#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
|