Jump to content

Counter Code


 Share

Recommended Posts

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.

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


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

Link to comment
Share on other sites

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

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]

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...