回复 1# creativewwz
代码比较乱....... 不是拿你的代码改的,主要是给你看看原理#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1) ;使用事件模式
Global $Stop = True, $s = 0 ;设置变量,$Stop = True时开始循环,$Stop = False时停止循环
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 175, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "stop") ;注册窗口关闭事件
$Progress1 = GUICtrlCreateProgress(8, 8, 597, 21)
$Button1 = GUICtrlCreateButton("开始", 226, 70, 179, 65)
GUICtrlSetOnEvent($Button1, "stop") ;注册按钮点击事件
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
If $Stop = True Then
If $s = 100 Then $s = 0
Sleep(200)
$s += 5
GUICtrlSetData($Progress1, $s)
ElseIf $Stop = False Then
EndIf
WEnd
Func stop()
If @GUI_CtrlId = $Button1 Then ;按钮点击事件
If $Stop = True Then
GUICtrlSetData($Button1, "开始")
$Stop = False
Else
GUICtrlSetData($Button1, "停止")
$Stop = True
EndIf
EndIf
If @GUI_CtrlId = $GUI_EVENT_CLOSE Then Exit
EndFunc ;==>stop
|