本帖最后由 afan 于 2009-7-23 14:58 编辑
我是新手,写了个小例子,不知道能不能帮到你~#include <GUIConstantsEx.au3>
Opt("GUIOnEventMode", 1)
Dim $tj = 0
$Form1 = GUICreate("test", 150, 70)
$Button1 = GUICtrlCreateButton("", 20, 10, 110, 25)
GUICtrlSetData(-1, '运行')
GUICtrlSetOnEvent(-1, "gui")
$Label1 = GUICtrlCreateLabel("运行中 ", 10, 45, 130, 15)
GUICtrlSetOnEvent(-1, "gui")
GUICtrlSetState(-1, $Gui_Hide)
GUISetOnEvent($GUI_EVENT_CLOSE, "gui")
GUISetState()
While 1
If $tj = 1 Then
MsgBox(0, "", "运行中")
Sleep(5000)
EndIf
WEnd
Exit
Func gui()
Switch @GUI_CtrlId
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$br = GUICtrlRead($Button1)
if $br = '运行' then
GUICtrlSetData($Button1, '停止')
AdlibEnable("xs", 500)
GUICtrlSetData($Label1, "运行中 ")
GUICtrlSetState($Label1, $Gui_Show)
$tj = 1
Elseif $br = '已暂停,点击继续' then
GUICtrlSetData($Button1, '停止')
AdlibEnable("xs", 500)
$tj = 1
Elseif $br = '停止' then
GUICtrlSetData($Button1, '运行')
AdlibDisable()
GUICtrlSetState($Label1, $Gui_Hide)
$tj = 0
endif
Case $Label1
$br = GUICtrlRead($Button1)
if $br = '停止' then
AdlibDisable()
GUICtrlSetData($Button1, '已暂停,点击继续')
$tj = 0
Elseif $br = '已暂停,点击继续' then
GUICtrlSetData($Button1, '停止')
AdlibEnable("xs", 500)
$tj = 1
endif
EndSwitch
EndFunc ;==>gui
Func xs()
$lb = GUICtrlRead($Label1)
if $lb = "运行中 |||||||||||||" then
GUICtrlSetData($Label1, "运行中 ")
else
GUICtrlSetData($Label1, $lb & "|")
endif
EndFunc ;==>xs
点击按钮可进行“运行”“停止”
点击进度条可“暂停”“继续” |