#include <Date.au3>
#include <StaticConstants.au3>
Global $bState = True
GUICreate('计时+时间循环', 300, 200)
GUICtrlCreateLabel('系统时间:', 10, 10, 60, 50)
$Time = GUICtrlCreateLabel(_Now(), 70, 10)
$Label1 = GUICtrlCreateLabel('准备就绪', 10, 60, 280, 50, $SS_CENTER)
GUICtrlSetFont(-1, 15, 800, 0, '楷体_GB2312')
$Button1 = GUICtrlCreateButton('开始', 40, 130, 100, 30)
$Button2 = GUICtrlCreateButton('暂停', 160, 130, 100, 30)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Button1
$i = 1
AdlibRegister('cont', 1000)
Case $Button2
If $bState = True Then
AdlibUnRegister('cont')
GUICtrlSetData($Label1, '暂停至' & $i & '秒')
GUICtrlSetData($Button2, '继续')
$bState = False
Else
$bState = True
GUICtrlSetData($Button2, '暂停')
AdlibRegister('cont', 1000)
EndIf
EndSwitch
If _Now() <> GUICtrlRead($Time) Then GUICtrlSetData($Time, _Now())
WEnd
Func cont()
GUICtrlSetData($Label1, '已开始' & $i & '秒')
$i += 1
EndFunc ;==>cont
|