本帖最后由 afan 于 2010-4-5 15:11 编辑 #include <Date.au3>
GUICreate('运行时间实时显示', 300, 100)
GUICtrlCreateLabel('本程序已运行:', 90, 70, 100, 15)
Dim $tl = GUICtrlCreateLabel('00天,00时,00分,00秒', 180, 70, 150, 15)
GUISetState()
Dim $timer = TimerInit(), $Day = 0
AdlibRegister('Timer', 500)
While 1
Switch GUIGetMsg()
Case -3
Exit
EndSwitch
WEnd
Func Timer()
Local $Secs, $Mins, $Hour, $Time, $ticks, $sTime
$ticks = Int(TimerDiff($timer)) * 5000 ;这里*5000是为了测试,将时间提速5000倍
If $ticks >= 86400000 Then
$Day += 1
$timer = TimerInit()
$ticks = 0
EndIf
_TicksToTime($ticks, $Hour, $Mins, $Secs)
$Time = StringFormat('%02s天,%02s时,%02s分,%02s秒', $Day, $Hour, $Mins, $Secs)
If $sTime <> $Time Then GUICtrlSetData($tl, $Time)
$sTime = $Time
EndFunc ;==>Timer
;注,第21行代码*5000是为了测试,将时间提速5000倍,实际应用则应取消*5000 |