;用事件驱动模式
#include <WindowsConstants.au3>
#include <GuiConstants.au3>
GuiCreate("MyGUI", 372, 88,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$Progress_1 = GuiCtrlCreateProgress(10, 10, 370, 20)
$Button_2 = GuiCtrlCreateButton("start", 10, 40, 60, 30)
$Button_3 = GuiCtrlCreateButton("pause", 80, 40, 60, 30)
$Button_4 = GuiCtrlCreateButton("exit", 150, 40, 70, 30)
Opt("GUIOnEventMode", 1)
Dim $start =0 ,$ostart
GuiSetState()
GUISetOnEvent($GUI_EVENT_CLOSE,"gui")
GUICtrlSetOnEvent($Button_2,"gui")
GUICtrlSetOnEvent($Button_3,"gui")
GUICtrlSetOnEvent($Button_4,"gui")
While 1
If $start >=0 Then
Sleep(50)
$start +=1
If $start >100 Then $start=0
If $start >=0 Then
$ostart = $start
GUICtrlSetData($Progress_1,$start)
Else
ContinueLoop
EndIf
EndIf
WEnd
Exit
Func gui()
Switch @GUI_CtrlId
Case $GUI_EVENT_CLOSE,$Button_4
Exit
Case $Button_2
$start=0
Case $Button_3
If $start=-100 Then
$start =$ostart
Else
$start=-100
EndIf
EndSwitch
EndFunc |