Sign in to follow this  
Followers 0
yachy

Counter Code

4 posts in this topic

Hi,

New to this forum so not sure if this is in the right place or not. I'm looking to make a counter that will display and count down a certain amount of time. Say I have a script that sleeps for 15 minutes and then will do whatever again. Looking for something that will display across the top of the screen and count down in seconds for however long the script sleeps. Is there something like this available or someone that can explain how I could do this?

Thanks for the help.

Share this post


Link to post
Share on other sites



Hi,

New to this forum so not sure if this is in the right place or not. I'm looking to make a counter that will display and count down a certain amount of time. Say I have a script that sleeps for 15 minutes and then will do whatever again. Looking for something that will display across the top of the screen and count down in seconds for however long the script sleeps. Is there something like this available or someone that can explain how I could do this?

Thanks for the help.

Here is one I found by GaFrost

#include <Date.au3>
HotKeySet("q", "quit")
Func quit()
   Exit
EndFunc ;==>quit
;~; -----------------------------------------------------
_CountDown(0, 5, 0)

Func _CountDown($Hours, $Mins, $Secs)
   Local $Sec
   While 1
      $sNewDate = StringFormat("%s/%s/%s %02i:%02i:%02i", @YEAR, @MON, @MDAY, $Hours, $Mins, $Secs)
      $Sec = @SEC
      ToolTip(StringFormat("%02i:%02i:%02i", $Hours, $Mins, $Secs))
      While 1
         If $Sec <> @SEC Then
            $Sec = @SEC
            $sNewDate = _DateAdd( 's', -1, $sNewDate)
            $sNewDate = StringSplit($sNewDate, " ")
            ToolTip($sNewDate[2])
            If $sNewDate[2] = "00:00:00" Then ExitLoop
            $sNewDate = $sNewDate[1] & " " & $sNewDate[2]
         EndIf
         Sleep(100)
      WEnd
   WEnd
EndFunc ;==>_CountDown


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Here is one I found by GaFrost

#include <Date.au3>
HotKeySet("q", "quit")
Func quit()
   Exit
EndFunc;==>quit
;~; -----------------------------------------------------
_CountDown(0, 5, 0)

Func _CountDown($Hours, $Mins, $Secs)
   Local $Sec
   While 1
      $sNewDate = StringFormat("%s/%s/%s %02i:%02i:%02i", @YEAR, @MON, @MDAY, $Hours, $Mins, $Secs)
      $Sec = @SEC
      ToolTip(StringFormat("%02i:%02i:%02i", $Hours, $Mins, $Secs))
      While 1
         If $Sec <> @SEC Then
            $Sec = @SEC
            $sNewDate = _DateAdd( 's', -1, $sNewDate)
            $sNewDate = StringSplit($sNewDate, " ")
            ToolTip($sNewDate[2])
            If $sNewDate[2] = "00:00:00" Then ExitLoop
            $sNewDate = $sNewDate[1] & " " & $sNewDate[2]
         EndIf
         Sleep(100)
      WEnd
   WEnd
EndFunc;==>_CountDown
Looks cool... have the Date.au3 so that I can run this and see if it what I'm looking for?

Thx for the help.

EDIT - Nevermind. I ran it like this and it ran just fine. Thx for the help, this should work out good for what I'm looking for. Thx much for the help.

Edited by yachy

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

ToolTip(StringFormat("%02i:%02i:%02i", $Hours, $Mins, $Secs))

ToolTip($sNewDate[2])
If $sNewDate[2] = "00:00:00" Then ExitLoop

changed to

If $sNewDate[2] = "00:00:00" Then ExitLoop 2

changed cause it will loop forever otherwise :think:

ToolTip(StringFormat("%02i:%02i:%02i", $Hours, $Mins, $Secs))

changed to

TrayTip("",StringFormat("%02i:%02i:%02i", $Hours, $Mins, $Secs),1)

ToolTip($sNewDate[2])

changed to

TrayTip("",$sNewDate[2],1)

now it shows up as a traytip which i like better as less annoying, due to the tooltip following the mouse, and this does not :(

Edited by Onoitsu2

Things I have made:[font="Trebuchet Ms"]_CheckTimeBlock UDF(LT)MOH Call Ignore List (MOH = Modem On Hold)[/font]

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