SpookMeister Posted March 15, 2006 Share Posted March 15, 2006 I tried looking for this the other day, and couldnt find exactly what I was looking for so I wrote my own. I'm posting it here in the hopes that if no-one else needs it... well, at least I'll be able to find it again the next time I do $begin = TimerInit() Sleep(3000) $dif = TimerDiff($begin) $sTime = _TimeReadable($dif) MsgBox(0, "Elapsed Time", $sTime) Func _TimeReadable($mili) $TotalSeconds = Int($mili / 1000); convert miliseconds to seconds $Hours = Int($TotalSeconds / 3600); 3600 seconds in an hour $Minutes = Int(($TotalSeconds - ($Hours * 3600)) / 60); 60 secs per min $Seconds = $TotalSeconds - (($Hours * 3600) + ($Minutes * 60)); leftovers If $Hours < 10 Then $Hours = "0" & $Hours If $Minutes < 10 Then $Minutes = "0" & $Minutes If $Seconds < 10 Then $Seconds = "0" & $Seconds $FormattedTime = $Hours & ":" & $Minutes & ":" & $Seconds Return $FormattedTime EndFunc ;==>_TimeReadable [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
jaenster Posted March 15, 2006 Share Posted March 15, 2006 nice , but i dont get the point of it.. you never use more then sleep(60000) (60 seconds) .. but again , nice -jaenster Link to comment Share on other sites More sharing options...
SpookMeister Posted March 15, 2006 Author Share Posted March 15, 2006 (edited) The whole top part was just to demonstrate. In my case I was creating a recording application, and I wanted to display how long the recording took. Edited March 15, 2006 by SpookMeister [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
Developers Jos Posted March 15, 2006 Developers Share Posted March 15, 2006 I tried looking for this the other day, and couldnt find exactly what I was looking for so I wrote my own. I'm posting it here in the hopes that if no-one else needs it... well, at least I'll be able to find it again the next time I do $begin = TimerInit() Sleep(3000) $dif = TimerDiff($begin) $sTime = _TimeReadable($dif) MsgBox(0, "Elapsed Time", $sTime) Func _TimeReadable($mili) $TotalSeconds = Int($mili / 1000); convert miliseconds to seconds $Hours = Int($TotalSeconds / 3600); 3600 seconds in an hour $Minutes = Int(($TotalSeconds - ($Hours * 3600)) / 60); 60 secs per min $Seconds = $TotalSeconds - (($Hours * 3600) + ($Minutes * 60)); leftovers If $Hours < 10 Then $Hours = "0" & $Hours If $Minutes < 10 Then $Minutes = "0" & $Minutes If $Seconds < 10 Then $Seconds = "0" & $Seconds $FormattedTime = $Hours & ":" & $Minutes & ":" & $Seconds Return $FormattedTime EndFunc ;==>_TimeReadable Isn't this the same as _TicksToTime() ? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
SpookMeister Posted March 15, 2006 Author Share Posted March 15, 2006 Sigh, leave it up to me to re-invent the wheel. Yeah, the same functionality is in _TicksToTime. I didn't even think to look at it. [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
Lakes Posted March 15, 2006 Share Posted March 15, 2006 Sigh, leave it up to me to re-invent the wheel. Yeah, the same functionality is in _TicksToTime. I didn't even think to look at it.I did similar here: http://www.autoitscript.com/forum/index.ph...opic=8492&st=15 2015 - Still no flying cars, instead blankets with sleeves. Link to comment Share on other sites More sharing options...
zaNergal Posted July 4, 2013 Share Posted July 4, 2013 If you need a nicely formatted time which include milliseconds (h:mm:ss.mmm): $ms = {wherever you get your milliseconds from} $time = StringFormat("%d:%.2d:%06.3f", (Floor($ms / 3600000)), (Floor(Mod($ms,3600000) / 60000)), (Mod(Mod($ms,3600000),60000) / 1000)) paw 1 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 4, 2013 Moderators Share Posted July 4, 2013 zaNergal,Please look at the date of the threads before you post in future - this one dates from over 7 years ago. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts