MrCheese Posted April 3, 2014 Share Posted April 3, 2014 Hi all, So after reading a few threads on timers, I haven't been able to do what I want to do. So in this example, the time to finish is calculated based on the initial desired value ($dollarmax) and the accumulative ($dollar) to determine how much longer it has to go until $dollar = $dollarmax It seems to work ok - but the tooltip displays the value in milliseconds. I've tried dividing all the variables by 1000 to get seconds, but that didn't work. Ideally, I would like the tooltip to display minutes and seconds remaining. This will insert into my larger code and will be updated after each change in $dollar. Thanks for your help. #include <Timers.au3> HotKeySet("{ESC}", "_Quit") Example() Func Example() $dollarmax= 100000 $dollar = 0 Local $starttime = _Timer_Init() While 1 $dollar = $dollar + 10 $Totaltime= $dollarmax / $dollar * $starttime $time2go = ($totaltime - $starttime) $time2gom = $time2go ;tired various /1000/60 here etc tooltip($time2gom) sleep(10000) WEnd EndFunc ;==>Example Func _Quit() Exit EndFunc ;==>_Quit Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 3, 2014 Moderators Share Posted April 3, 2014 MrCheese,Doing any kind of manipulation of timer timestamps ususally ends in tears - the returned value from an Init function should only ever be used as the parameter for the corresponding Diff function. The Help file page for TimerInit makes this quite clear and as far as I know it applies to the UDF equivalent as well. Given the number of countdown timer threads on the forum, I am surprised that you have not been able to find a suitable version to use. Here is one I have used in the past:#include <Date.au3> HotKeySet("{ESC}", "_Quit") Example() Func Example() $iDollarMax = 140 ; Units are seconds ; Determine end time $sEnd = _DateAdd("s", $iDollarMax, _NowCalc()) ; Store current second $iSec = @SEC While 1 ; Wait until second changes Do Sleep(10) Until $iSec <> @SEC ; Store new second $iSec = @SEC ; Calculate time difference $iTime2GoSec = _DateDiff("s", _NowCalc(), $sEnd) ; Convert to Min and Sec $iTime2GoMin = Int($iTime2GoSec / 60) $iTime2GoSec = Mod($iTime2GoSec, 60) ; Display result - adding padding 0 to Sec if required ToolTip($iTime2GoMin & ":" & StringFormat("%02i", $iTime2GoSec)) WEnd EndFunc ;==>Example Func _Quit() Exit EndFunc ;==>_QuitI hope that it does what you want - please ask if you have any questions. M23 SkysLastChance 1 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...
MrCheese Posted April 5, 2014 Author Share Posted April 5, 2014 Hi M23, Thank you for your help! I haven't had a chance to test it out yet and work it into my code. I'll let you know if I have any other questions or difficulties. Cheers, Mr Cheese 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