Sign in to follow this  
Followers 0
Ventura

Timer show miliseconds

4 posts in this topic

I have a timer that uses _TicksToTime which normally shows Hours, Mins and Seconds... which isn't what I want.

I wanted the timer to show like this Mins:Seconds:Miliseconds

Basically so it will look like 1:53.964 which is 1 mins 53 secs and 964 ms  

The usual way they use for sports racing..

#Include <Date.au3>

Global $iHours = 0, $iMins = 0, $iSecs = 0

$Timer = TimerInit()
While 1
Sleep(100)
$Time = TimerDiff($Timer)
_TicksToTime($Time, $iHours, $iMins, $iSecs)
ToolTip(StringFormat( "%02i:%02i:%02i:%02i", $iHours, $iMins, $iSecs))
WEnd

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

This should do ya. Let me know what you think.

 

#include <Date.au3>

Global $iHours = 0, $iMins = 0, $iSecs = 0, $Seconds, $Minutes

$Timer = TimerInit()

While 1
    Sleep(100)
    $Time = TimerDiff($Timer)
    $Time = Round($Time)

    If $Time > 1000 Then
        $Seconds += 1
        $Timer = TimerInit()
    EndIf

    If $Seconds > 60 Then
        $Minutes += 1
        $Seconds = 0
    EndIf

    $Display = $Minutes & ":" & $Seconds & ":" & $Time

    ToolTip($Display)
WEnd

 

Edited by Damein

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Share this post


Link to post
Share on other sites

This has been asked a few times, but here's another solution.

Global $iStart = TimerInit()
Sleep(5525)
ConsoleWrite(TicksToMinsSecsMilis($iStart) & @LF)

Func TicksToMinsSecsMilis(Const $iTimer)
    Local $iMilis = Int(Mod(TimerDiff($iTimer), 1000))
    Local $fTime = TimerDiff($iTimer) / 1000
    Local $iMins = Int($fTime / 60)
    Local $iSecs = Floor(Mod($fTime, 60))

    Return StringFormat("%02i:%02i:%02i", $iMins, $iSecs, $iMilis)
EndFunc   ;==>TicksToMinsSecsMilis

Share this post


Link to post
Share on other sites

Both of them works thanks :)

@Damein It is working, just that there is 4 digits showing after every 999+, even sometimes showing 1100 for the miliseconds.

@InunoTaishou I have been searching it for hours, I haven't seen one exactly like mine. So about your code I tried it works, the only thing is that it doesn't add leading zero to numbers below 100 ms, I have fixed it by making the StringFormat %03i for ms.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0