Jump to content

Timer Help Need


Recommended Posts

Hi it's been a long time. :mellow:

Anyways here's my code:

$TimeToCountSeconds = 0
$TimeToCountMinutes = 1
$TimeToCountHours = 0
$TimeHours = 0
$TimeMinutes = 0
$TimeSeconds = 0

Do
    Sleep(1000)
    $TimeSeconds = $TimeSeconds +1
    If $TimeSeconds == 60 Then
        $TimeMinutes = $TimeMinutes +1
        $TimeSeconds = 0
    ElseIf $TimeMinutes == 60 Then
        $TimeHours = $TimeHours +1
        $TimeMinutes = 0
    EndIf
    ToolTip ('Counting from: ' & $TimeHours & ' Hours ' & $TimeMinutes & ' Minutes ' & $TimeSeconds & ' Seconds ' & @CRLF & ' Counting to: ' & $TimeToCountHours & ' Hours ' & $TimeToCountMinutes & ' Minutes ' & $TimeToCountSeconds & ' Seconds ', 0, 0)

Until

MsgBox(64, 'Times Up!', 'The Time Is Up!')

What I'm trying to do is make it so that when $TimeHours, $TimeMinutes and $TimeSeconds reach to the required number from the variable $TimeToCountHours, $TimeToCountMinutes and $TimeToCountSeconds ; After it reaches the required number you pop up MsgBox. But one thing, if i try

Until $TimeSeconds == $TimeToCountSeconds

I won't be able to check for the other 2: Hours and Minutes. Also, if i try to check for seconds, and the hours is 0 and minutes is 10 and seconds is 0, i wouldn't be able to get to 10 minutes because the 0 seconds makes it look like the counting is done. (only if i do the code posted above.)

So how can i make it so that it checks all the variables to make it go to the required number. (Like the Hours is 1 and minutes 10 and seconds 0. Then it keeps on going on and on starting from 0 hours, 0 minutes, and 0 seconds until u reach 1 hour and 10 minutes without ending at 0 hours, 0 minutes and 0 seconds.)

Edited by zero57

[font="Arial Black"][u]zero57[/u][/font]

Link to comment
Share on other sites

Its never an easy task trying to re-invent the wheel.

If $blah = $blah2 And $blah3 = $blah4 And $blah5 = $blah6 Then
;etc...
EndIf

Or have a look at the Timers UDF.

Okay thanks, i see the logic between the if and the and's. One thing though, how can u add the If to Until...? Heres my code right now.

$TimeToCountSeconds = 0
$TimeToCountMinutes = 1
$TimeToCountHours = 0
$TimeHours = 0
$TimeMinutes = 0
$TimeSeconds = 0

Do
    Sleep(1000)
    $TimeSeconds = $TimeSeconds +1
    If $TimeSeconds == 60 Then
        $TimeMinutes = $TimeMinutes +1
        $TimeSeconds = 0
    ElseIf $TimeMinutes == 60 Then
        $TimeHours = $TimeHours +1
        $TimeMinutes = 0
    EndIf
    ToolTip ('Counting from: ' & $TimeHours & ' Hours ' & $TimeMinutes & ' Minutes ' & $TimeSeconds & ' Seconds ' & @CRLF & ' Counting to: ' & $TimeToCountHours & ' Hours ' & $TimeToCountMinutes & ' Minutes ' & $TimeToCountSeconds & ' Seconds ', 0, 0)

Until If $TimeSeconds == $TimeToCountSeconds And $TimeMinutes == $TimeToCountMinutes And $TimeHours == $TimeToCountHours Then
    MsgBox(64, 'Times Up!', 'The Time Is Up!')
EndIf

If i try to add If right after Until, i get errors:

C:\Documents and Settings\<my username>\Desktop\New AutoIt v3 Script.au3(30,7) : ERROR: syntax error
Until If
~~~~~~^
C:\Documents and Settings\<my username>\Desktop\New AutoIt v3 Script.au3(30,122) : ERROR: syntax error
Until If $TimeSeconds == $TimeToCountSeconds And $TimeMinutes == $TimeToCountMinutes And $TimeHours == $TimeToCountHours Then
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\<my username>\Desktop\New AutoIt v3 Script.au3(32,1) : ERROR: syntax error
EndIf

Sorry for the noob questions.

Also, where can i find this Timers UDF?

[font="Arial Black"][u]zero57[/u][/font]

Link to comment
Share on other sites

$TimeToCountSeconds = 0
$TimeToCountMinutes = 1
$TimeToCountHours = 0
$TimeHours = 0
$TimeMinutes = 0
$TimeSeconds = 0

Do
    Sleep(1000)
    $TimeSeconds = $TimeSeconds +1
    If $TimeSeconds == 60 Then
        $TimeMinutes = $TimeMinutes +1
        $TimeSeconds = 0
    ElseIf $TimeMinutes == 60 Then
        $TimeHours = $TimeHours +1
        $TimeMinutes = 0
    EndIf
    ToolTip ('Counting from: ' & $TimeHours & ' Hours ' & $TimeMinutes & ' Minutes ' & $TimeSeconds & ' Seconds ' & @CRLF & ' Counting to: ' & $TimeToCountHours & ' Hours ' & $TimeToCountMinutes & ' Minutes ' & $TimeToCountSeconds & ' Seconds ', 0, 0)

Until $TimeSeconds == $TimeToCountSeconds And $TimeMinutes == $TimeToCountMinutes And $TimeHours == $TimeToCountHours

MsgBox(64, 'Times Up!', 'The Time Is Up!')

The timers udf can be found in the helpfile under User defined function notes > Timers management.

GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.
Link to comment
Share on other sites

$TimeToCountSeconds = 0
$TimeToCountMinutes = 1
$TimeToCountHours = 0
$TimeHours = 0
$TimeMinutes = 0
$TimeSeconds = 0

Do
    Sleep(1000)
    $TimeSeconds = $TimeSeconds +1
    If $TimeSeconds == 60 Then
        $TimeMinutes = $TimeMinutes +1
        $TimeSeconds = 0
    ElseIf $TimeMinutes == 60 Then
        $TimeHours = $TimeHours +1
        $TimeMinutes = 0
    EndIf
    ToolTip ('Counting from: ' & $TimeHours & ' Hours ' & $TimeMinutes & ' Minutes ' & $TimeSeconds & ' Seconds ' & @CRLF & ' Counting to: ' & $TimeToCountHours & ' Hours ' & $TimeToCountMinutes & ' Minutes ' & $TimeToCountSeconds & ' Seconds ', 0, 0)

Until $TimeSeconds == $TimeToCountSeconds And $TimeMinutes == $TimeToCountMinutes And $TimeHours == $TimeToCountHours

MsgBox(64, 'Times Up!', 'The Time Is Up!')

The timers udf can be found in the helpfile under User defined function notes > Timers management.

Ty so much, never knew it would be that easy... I'm so dumb lawl. Well Thx for telling me where to find the Timers UDF too!

[font="Arial Black"][u]zero57[/u][/font]

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...