Jump to content

countdown


danusko
 Share

Recommended Posts

Please what i do wrong? I want only set variable f.e. 5 minutes, and i want that show me countdown in minutes, hours and second. But my script doesnt works. Please help. Thanke you.

#include "C:\My documents\docs\AutoIt\Include\Date.au3"
HotKeySet("q", "quit")
Func quit()
    exit
EndFunc
; -----------------------------------------------------
Global $Sec, $Min, $Hour, $Time
Global $Sec2, $Min2, $Hour2, $Time2


$StartTicks = _TimeToTicks(@HOUR,@MIN,@SEC)
$EndTicks = $StartTicks + 60 * 60 * 1000
$odpocet = $EndTicks - $StartTicks

While 1

$odpocet = $EndTicks - 1 * 60 * 1000
_TicksToTime($odpocet,$Hour2,$Min2,$Sec2)

ToolTip($Hour2 & ":" & $Min2 & ":" & $Sec2)


; MsgBox(262144,'' , 'New Time:' &  $Hour & ":" & $Min & ":" & $Sec)
; $EndTicks = $StartTicks + 45 * 60 * 1000

    Sleep(100)
WEnd
Link to comment
Share on other sites

i got it

Global $Sec, $Min, $Hour, $Time
Global $Sec2, $Min2, $Hour2, $Time2


$StartTicks = _TimeToTicks(@HOUR, @MIN, @SEC)
$EndTicks = $StartTicks + 1 * 60 * 1000
$odpocet = $EndTicks - $StartTicks

do
   $odpocet = $odpocet - 1000
 _TicksToTime($odpocet, $Hour2, $Min2, $Sec2)

 ToolTip($Hour2 & ":" & $Min2 & ":" & $Sec2)

  Sleep(1000)

until $odpocet = 0
Link to comment
Share on other sites

i got it

Global $Sec, $Min, $Hour, $Time
Global $Sec2, $Min2, $Hour2, $Time2


$StartTicks = _TimeToTicks(@HOUR, @MIN, @SEC)
$EndTicks = $StartTicks + 1 * 60 * 1000
$odpocet = $EndTicks - $StartTicks

do
   $odpocet = $odpocet - 1000
_TicksToTime($odpocet, $Hour2, $Min2, $Sec2)

ToolTip($Hour2 & ":" & $Min2 & ":" & $Sec2)

  Sleep(1000)

until $odpocet = 0

Thought you were wanting a 5 minute countdown?

#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

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

and yet another way

#include <Date.au3>
HotKeySet("!q", "quit")
HotKeySet("!s", "stop")
HotKeySet("!r", "restart")
; -----------------------------------------------------

Global $Hours, $Mins, $Secs, $sNewDate, $Sec = @SEC
restart()

While 1
  ; can do other things here
   Sleep(10)
WEnd

Func _CountDown()
   If $Sec <> @SEC Then
      $Sec = @SEC
      $sNewDate = _DateAdd( 's', -1, $sNewDate)
      $sNewDate = StringSplit($sNewDate, " ")
      ToolTip($sNewDate[2])
      If $sNewDate[2] = "00:00:00" Then AdlibDisable()
      $sNewDate = $sNewDate[1] & " " & $sNewDate[2]
   EndIf
EndFunc  ;==>_CountDown

Func quit()
   Exit
EndFunc  ;==>quit

Func stop()
   AdlibDisable()
EndFunc  ;==>stop

Func restart()
   $Hours = 0
   $Mins = 5
   $Secs = 0
   $sNewDate = StringFormat("%s/%s/%s %02i:%02i:%02i", @YEAR, @MON, @MDAY, $Hours, $Mins, $Secs)
   $Sec = @SEC
   ToolTip(StringFormat("%02i:%02i:%02i", $Hours, $Mins, $Secs))
   AdlibEnable("_CountDown")
EndFunc  ;==>restart
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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