找回密码
 加入
搜索
查看: 1970|回复: 3

[AU3基础] 我想做一个程序运行时间实时显示的程序,帮忙~

[复制链接]
发表于 2010-4-5 13:38:21 | 显示全部楼层 |阅读模式
我有个程序想实时显示运行了多长时间,格式:XX天XX时XX分XX秒,一点头绪没有,大家帮忙看看怎么做啊,谢谢啦~
发表于 2010-4-5 14:40:51 | 显示全部楼层
发表于 2010-4-5 15:09:21 | 显示全部楼层
本帖最后由 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
 楼主| 发表于 2010-4-5 18:05:39 | 显示全部楼层
试试,谢谢!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-7 21:53 , Processed in 0.078869 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表