Terenz Posted February 26, 2017 Share Posted February 26, 2017 (edited) A friend of mine ask me to make a 24h timer for check how long require some task on his PC. I'll do it my friend, i'm a super expert of this things! In my mind was easy but seems a timer has a "couple" of rules. $sHour = 23 $sMin = 57 $sSec = @SEC $sHour = StringFormat("%02s", $sHour) $sMin = StringFormat("%02s", $sMin) Do If $sSec <> @SEC Then $sSec = @SEC Select ;~ Case $sSec = "00" And $sMin = "59" ;~ $sHour += 1 ;~ $sMin = 0 ;~ If $sMin < 10 Then $sMin = StringFormat("%02s", $sMin) ;~ If $sHour < 10 Then $sHour = StringFormat("%02s", $sHour) Case $sSec = "00" And Not $sMin = "59" $sMin += 1 If $sMin < 10 Then $sMin = StringFormat("%02s", $sMin) ;~ Case $sHour = "23" And $sMin = "00" And $sSec = "00" ;~ $sHour = 0 ;~ StringFormat("%02s", $sHour) EndSelect ConsoleWrite($sHour & ":" & $sMin & ":" & $sSec & @CRLF) EndIf Until 0 Well 'im stuck, that things doesn't satisfy me and not work. Example i don't know how to start again from 00:00:00. If i'll check 23:59:59 i'll update the hour one second early, if i'll check 23:00:00 can be two different time 23:00:00 and 00:00:00 Thanks for help me to resolve that code. Edited February 26, 2017 by Terenz Nothing is so strong as gentleness. Nothing is so gentle as real strength Link to comment Share on other sites More sharing options...
JohnOne Posted February 26, 2017 Share Posted February 26, 2017 What about $sHour = 23 $sMin = 59 $SecsPassed = 55 ; obviously set all above to 0 $sSec = 60 Do If $sSec <> @SEC Then $sSec = @SEC $SecsPassed += 1 If $SecsPassed > 59 Then $SecsPassed = 0 $sMin += 1 If $sMin > 59 Then $sHour += 1 EndIf EndIf if $sHour > 23 Then $sHour = 0 if $sMin > 59 Then $sMin = 0 ConsoleWrite(StringFormat("%02s", $sHour) & ":" & StringFormat("%02s", $sMin) & ":" & StringFormat("%02s", $SecsPassed) & @CRLF) EndIf Sleep(10) Until 0 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
mikell Posted February 26, 2017 Share Posted February 26, 2017 and what about $hour = 23 $min = 59 $sec = 55 ; obviously set all above to 0 Global $ticks = $hour*3600 + $min*60 + $sec AdlibRegister("_Display", 1000) While 1 Sleep(10) Wend Func _Display() Local $sc, $mn, $hr $sc = Mod($ticks, 60) $mn = Mod($ticks/60, 60) $hr = Mod($ticks/3600, 24) $str = StringFormat("%02i", $hr) & ":" & StringFormat("%02i", $mn) & ":" & StringFormat("%02i", $sc) Tooltip($str, 0, 0) $ticks += 1 EndFunc Link to comment Share on other sites More sharing options...
UEZ Posted February 26, 2017 Share Posted February 26, 2017 @mikell: your StringFormat line can be shorten to: $str = StringFormat("%02i:%02i:%02i", $hr, $mn, $sc) Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
mikell Posted February 26, 2017 Share Posted February 26, 2017 Absolutely right. I hastily copypasted the line from J1's post - and apologize for my laziness Link to comment Share on other sites More sharing options...
Terenz Posted February 26, 2017 Author Share Posted February 26, 2017 (edited) Correct me if i'm wrong, but i think AdlibRegister is unnecessary. It call the function every second, is the same inside the loop since we check for @SEC? Considered a loop is required for the script to be alive, put everything there isn't better and we saving an Adlib? Just my curiosity, both script work fine for what i have see Edited February 26, 2017 by Terenz Nothing is so strong as gentleness. Nothing is so gentle as real strength Link to comment Share on other sites More sharing options...
Gianni Posted February 26, 2017 Share Posted February 26, 2017 (edited) @Terenz in which way do you think to use the timer to "check how long require some task on his PC"? edit: ???? Local $iDelay = 0 Local $timer = 86390 ; start timer at 23:59:50 as example While True Do If $iDelay <> @SEC Then $iDelay = @SEC ConsoleWrite(StringFormat("%02d:%02d:%02d", Floor($timer / 3600), Mod(Floor($timer / 60), 60), Mod($timer, 60)) & @CRLF) $timer += 1 EndIf Until $timer = 86400 ; total seconds in 24 Hours $timer = 0 ; reset timer WEnd Edited February 26, 2017 by Chimp Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
genius257 Posted March 6, 2017 Share Posted March 6, 2017 Can windows task scheduler be a solution, or will the script be doing anything in between the 24h besides waiting? My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser Link to comment Share on other sites More sharing options...
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