cypher175 Posted May 9, 2009 Share Posted May 9, 2009 (edited) How Can I Display the TimerDiff($Timer) in (Hour, Min, Sec) (00:00:00) Format for the ToolTip..?? while 1 $Timer = TimerInit() sleep(10000) $Time = TimerDiff($Timer) ToolTip($Time) Sleep(1500) wend Edited May 9, 2009 by cypher175 Link to comment Share on other sites More sharing options...
Yashied Posted May 9, 2009 Share Posted May 9, 2009 func _Diff2Time($TimerDiff) dim $HMS[3] $HMS[2] = Int($TimerDiff / 1000) $HMS[1] = $HMS[2] - Mod($HMS[2], 60) $HMS[2] -= $HMS[1] $HMS[1] /= 60 $HMS[0] = $HMS[1] - Mod($HMS[1], 60) $HMS[1] -= $HMS[0] $HMS[0] /= 60 return $HMS endfunc; _Diff2Time local $Diff = 60000 local $Time = _Diff2Time($Diff) ConsoleWrite($Time[0] & ':' & $Time[1] & ':' & $Time[2] & ' (Hour:Min:Sec)' & @CR) My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
JackDinn Posted May 9, 2009 Share Posted May 9, 2009 (edited) Ahh well beaten , never mind $time = 0 $Timer = TimerInit() While 1 $time = TimerDiff($Timer) Sleep(1000) $hour = Floor($time / 3600000) $remanH = Mod($time, 3600000) $min = Floor($remanH / 60000) $remanM = Mod($remanH, 60000) $sec = Floor($remanM / 1000) ToolTip($hour & ":" & $min & ":" & $sec) WEnd Edited May 9, 2009 by JackDinn Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 9, 2009 Moderators Share Posted May 9, 2009 cypher175, You can let Autoit do all the sums for you if you prefer: ;-)#Include <Date.au3> Global $iHours = 0, $iMins = 0, $iSecs = 0 $iBegin = TimerInit() Sleep(5000) $iEnd = TimerDiff($iBegin) _TicksToTime($iEnd, $iHours, $iMins, $iSecs) ConsoleWrite(StringFormat("%02d:%02d:%02d", $iHours, $iMins, $iSecs) & @CRLF) 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...
JackDinn Posted May 9, 2009 Share Posted May 9, 2009 ahh, we both forgot about ticksToTime () , now you mention it i remember reading it briefly ages ago but never used it, use it or lose it ! lol Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
batman009 Posted June 3, 2009 Share Posted June 3, 2009 Hello,im having same troubles here.. any inputs would be great!Thanks!simulation assurance vie Link to comment Share on other sites More sharing options...
oMBRa Posted June 3, 2009 Share Posted June 3, 2009 we cant imagine your problems Link to comment Share on other sites More sharing options...
BrettF Posted June 3, 2009 Share Posted June 3, 2009 My microwave isn't working. Can we fix that too? What problem are you having specifically? Post something that replicates it. Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
mbunds Posted June 2, 2016 Share Posted June 2, 2016 (edited) First, a million thanks to Yashied, JackDinn, and Melba 23 for providing very useful examples. The final routine I constructed is a hybrid borrowing logic from all three examples, plus additional logic and a formatted string for presenting milliseconds. It is surprisingly accurate despite not using API calls to the system clock. This routine will be used for other purposes, but it was initially created to record and trend the time required for an external application to launch and become active. In this instance, millisecond accuracy wasn't important since the external program requires around 30 seconds to launch, but other routines will be timing data transfer response times which will require sub-second accuracy. ;Millisecond Timer (First used to record elapsed time for GUI Time Clock Launch) ;Thanks to Yashied, JackDinn, and Melba23 on the AutoIt forums! #include <DateTimeConstants.au3> #include <Date.au3> #include <MsgBoxConstants.au3> #include <Timers.au3> Global $tmrStartTime Global $tmrELTime Global $tmrCalc Global $iHours = 0 Global $iMins = 0 Global $iSecs = 0 Global $iMSecs = 0 $tmrStartTime = TimerInit() ;(Do Stuff that takes a while) $tmrELTime = TimerDiff($tmrStartTime) _TicksToTime($tmrELTime, $iHours, $iMins, $iSecs) $tmrCalc = $iHours * 3600000 $tmrCalc = $tmrCalc + $iMins * 60000 $tmrCalc = $tmrCalc + $iSecs * 1000 $iMSecs = Int(Number($tmrELTime) - Number($tmrCalc)) $logtext = "Function cmdLTC - GUI TC Loading Elapsed Time: " & StringFormat("%02d:%02d:%02d.%03d", $iHours, $iMins, $iSecs, $iMSecs) writelog($logtext) The routine assigns time values automatically from the TimerDiff function for hours, minutes, and seconds as usual, but the millisecond value is calculated by back-converting each time value for hours, minutes, and seconds to milliseconds, adding them together, and subtracting this total from the raw value returned by TimerDiff. The result is stored in $iMSecs, and then formatted with the addition of the .%03d filter, and the $iMsecs variable to the string list. I suppose I could have tried simply adding the iMSecs variable to the _TicksToTime function, which I didn't because I'm sort of gutless that way. Plus, the AutoIt help files said that the _TicksToTime function only returns hours, minutes and seconds, so I was convinced that if I attempted to add the variable, the system would probably crash, delete the OS, and catch fire, or worse, throw up an "invalid parameters" error ;-) Edited June 2, 2016 by mbunds Stripped some irrelevant code from the code example. 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