Jump to content
Sign in to follow this  
Hest

Fast timer

Recommended Posts

Hest

I want to make a clock that runs X times faster than normal, but I'm a bit confused about how to approach. What is the best way to do this?


Software:Model Train Calculator (Screen)Autoit3 beginner!

Share this post


Link to post
Share on other sites
Dampe

Have a look at TimerInit() and the other Timer() functions in the help file, I'd say that is your best bet.

Quick and dirty example:

Local $Timer1, $Timer2
Local $Hours1=0, $Hours2=0, $Minutes1=0, $Minutes2=0, $Seconds1=0, $Seconds2=0

Local $Timer1 = TimerInit()
Local $Timer2 = TimerInit()
Local $FirstProc =0 , $SecondProc=0


While 1
    
    If TimerDiff ($Timer1) >= 1000 Then
        $Timer1= TimerInit()
        $Seconds1 += 1
        $Mil1 = 0
    EndIf
    If $Seconds1 = 60 Then
        $Minutes1 +=1
        $Seconds1 = 0
    EndIf
    If $Minutes1 = 60 Then
        $Hours1 +=1
        $Minutes1 = 0
    EndIf
    
    If TimerDiff ($Timer2) >= 500 Then
        $Timer2= TimerInit()
        $Seconds2 += 1
    EndIf
    If $Seconds2 = 60 Then
        $Minutes2 +=1
        $Seconds2 = 0
    EndIf
    If $Minutes2 = 60 Then
        $Hours2 +=1
        $Minutes2 = 0
    EndIf
    
    ToolTip ("Normal timer: " & $Hours1 & ":" & $Minutes1 & ":" & $Seconds1 & @CRLF & "Double speed timer: " & $Hours2 & ":" & $Minutes2 & ":" & $Seconds2, 50, 50, "Timer example")
    
WEnd

Share this post


Link to post
Share on other sites
Hest

Thx, I know I have to use the timer functions, but I need a little guidance on how I should approach this scaling. I need the time to run beteween x5 or x8 times faster.

Is the easiest way just to find the time difference and then * 8?


Software:Model Train Calculator (Screen)Autoit3 beginner!

Share this post


Link to post
Share on other sites
Dampe

Thx, I know I have to use the timer functions, but I need a little guidance on how I should approach this scaling. I need the time to run beteween x5 or x8 times faster.

Is the easiest way just to find the time difference and then * 8?

That's probably easier actually, I never thought about that :D

You'll need to do some mod division to make it work that way though.


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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.