本帖最后由 lion.lee 于 2011-8-2 11:59 编辑
因为这个问题困扰了很久,在论坛搜索了很多大牛的代码,但离自己的要求多少有点距离,终于在不懈的尝试下完成了符合自己要求的东东,为更多像我一样的菜鸟,特将源码发上来,给大家参考一下#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 449, 192, 114)
$Button1 = GUICtrlCreateButton("开始", 48, 224, 113, 33)
$Button2 = GUICtrlCreateButton("暂停", 192, 224, 113, 33)
$Button3 = GUICtrlCreateButton("结束", 336, 224, 113, 33)
$Button4 = GUICtrlCreateButton("显示", 192, 136, 113, 33)
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "gui")
GUICtrlSetOnEvent($Button1, "gui")
GUICtrlSetOnEvent($Button2, "gui")
GUICtrlSetOnEvent($Button3, "gui")
#EndRegion ### END Koda GUI section ###
Global $start = False, $ipstart = True
While 1
If $ipstart = True Then
For $i = 1 To 40 Step 1
If $start = True And $ipstart = True Then
GUICtrlSetData($Button4, $i)
Else
While $start = False
Sleep(100)
WEnd
EndIf
Sleep(100)
Next
$ipstart = False
EndIf
Sleep(100)
WEnd
Func gui()
Switch @GUI_CtrlId
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$start = True
$ipstart = True
$i = 1
Case $Button2
If $start = True Then
$start = False
GUICtrlSetData($Button2, "继续")
Else
$start = True
GUICtrlSetData($Button2, "暂停")
EndIf
Case $Button3
$ipstart = False
EndSwitch
EndFunc ;==>gui
|