danusko Posted February 23, 2006 Posted February 23, 2006 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
danusko Posted February 23, 2006 Author Posted February 23, 2006 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
GaryFrost Posted February 23, 2006 Posted February 23, 2006 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.
GaryFrost Posted February 23, 2006 Posted February 23, 2006 (edited) and yet another way expandcollapse popup#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 February 23, 2006 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now