NutherNoob Posted January 30, 2007 Share Posted January 30, 2007 (edited) I'm having trouble with a loop I'd like to insert so that the time in the tooltip counts down. Where should I put the loop? What kind of loop should I use? Btw, I used Adlibenable() on the numbers in the sleep() line, it worked fine last nite, now it doesnt so I've reverted back. Any ideas why? Thanx Func whatever() blah blah blah...... ; Tooltip line needs to be in a loop and counting down........ For $I = 0 To $NumTimeFields - 1 If GUICtrlRead($CoordsField[$I])="" Then ContinueLoop MouseClick("right",StringLeft(GUICtrlRead($CoordsField[$i]),StringInStr(GUICtrlRead($CoordsField[$i]),",")-1),StringTrimLeft(GUICtrlRead($CoordsField[$i]),StringInStr(GUICtrlRead($CoordsField[$i]),","))) Sleep(3000) MouseClick("left", (StringLeft(GUICtrlRead($CoordsField[$i]),StringInStr(GUICtrlRead($CoordsField[$i]),",")-1) + $XSpot), (StringTrimLeft(GUICtrlRead($CoordsField[$i]),StringInStr(GUICtrlRead($CoordsField[$i]),",")) + $YSpot)) ToolTip("Now running number " & ($I+1) & "....Waiting " & GUICtrlRead($HourFields[$I]) & " hours, " & GUICtrlRead($MinuteFields[$I]) & " minutes, " & GUICtrlRead($SecondFields[$I]) & " seconds.", 210, 3) sleep((GUICtrlRead($HourFields[$I])*3600000) + (GUICtrlRead($MinuteFields[$I])*60000)+ (GUICtrlRead($SecondFields[$I])*1000)) ; countdown Next MsgBox(48+0, "", "completed.") EndFunc Edited January 30, 2007 by NutherNoob Link to comment Share on other sites More sharing options...
Uten Posted January 31, 2007 Share Posted January 31, 2007 (edited) Holly molly, quite some long (unreadable) lines of code you have there.. Did you notice this line in the help file A Tooltip will appear until the script terminates or ToolTip("") is called. Func ToolTipSleep($msg, $ms) Local $c, $t =TimerInit() Do Sleep(25) ToolTip("") ToolTip($msg & " " & TimerDiff($t) & "/" & $ms) Until TimerDiff($t) >= $ms EndFunc EDIT: Not really sure you need ToolTip("") though. Edited January 31, 2007 by Uten Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
NutherNoob Posted January 31, 2007 Author Share Posted January 31, 2007 Holly molly, quite some long (unreadable) lines of code you have there.. Did you notice this line in the help file Func ToolTipSleep($msg, $ms) Local $c, $t =TimerInit() Do Sleep(25) ToolTip("") ToolTip($msg & " " & TimerDiff($t) & "/" & $ms) Until TimerDiff($t) >= $ms EndFunc EDIT: Not really sure you need ToolTip("") though.Thanx, but how do I fit this in my script? I've been messing with it but it doesnt countdown to 0. (Maybe, if I could see how this fits in my script, I'll understand why it wont work ) Link to comment Share on other sites More sharing options...
Uten Posted January 31, 2007 Share Posted January 31, 2007 A countdown towards zero in milliseconds would require $ms - TimerDiff($t)oÝ÷ Øò¢ìÖ§¢Ø^®Ø¦yú+«r¢ì"XZ½ëhr·µë(éh'¢¸4äÄ"جº{^²×jw_®ëh¦æÊtý +)à¢yâÆØ^±çZÊË("¯zz)§-Æ¥Á¬¨~׬¶)àjëh×6Func whatever() Local $msg, $ms blah blah blah...... ; Tooltip line needs to be in a loop and counting down........ For $I = 0 To $NumTimeFields - 1 If GUICtrlRead($CoordsField[$I])="" Then ContinueLoop MouseClick("right",StringLeft(GUICtrlRead($CoordsField[$i]),StringInStr(GUICtrlRead($CoordsField[$i]),",")-1),StringTrimLeft(GUICtrlRead($CoordsField[$i]),StringInStr(GUICtrlRead($CoordsField[$i]),","))) Sleep(3000) MouseClick("left", (StringLeft(GUICtrlRead($CoordsField[$i]),StringInStr(GUICtrlRead($CoordsField[$i]),",")-1) + $XSpot), (StringTrimLeft(GUICtrlRead($CoordsField[$i]),StringInStr(GUICtrlRead($CoordsField[$i]),",")) + $YSpot)) $msg = "Now running number " & ($I+1) & "....Waiting " & GUICtrlRead($HourFields[$I]) & " hours, " & GUICtrlRead($MinuteFields[$I]) & " minutes, " & GUICtrlRead($SecondFields[$I]) & " seconds." $ms = (GUICtrlRead($HourFields[$I])*3600000) + (GUICtrlRead($MinuteFields[$I])*60000)+ (GUICtrlRead($SecondFields[$I])*1000) ToolTipSleep($msg, $ms, 210, 3) #cs ToolTip("Now running number " & ($I+1) & "....Waiting " & GUICtrlRead($HourFields[$I]) & " hours, " & GUICtrlRead($MinuteFields[$I]) & " minutes, " & GUICtrlRead($SecondFields[$I]) & " seconds.", 210, 3) sleep((GUICtrlRead($HourFields[$I])*3600000) + (GUICtrlRead($MinuteFields[$I])*60000)+ (GUICtrlRead($SecondFields[$I])*1000)) ; countdown #ce Next MsgBox(48+0, "", "completed.") EndFunc Func ToolTipSleep($msg, $ms, $left, $top) ;Might have goofed on left and top Local $c, $t =TimerInit() Do Sleep(25) ToolTip("") ToolTip($msg & ":::::" & ($ms - TimerDiff($t)) , $left, $top) Until TimerDiff($t) >= $ms EndFunc Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
NutherNoob Posted February 1, 2007 Author Share Posted February 1, 2007 Thanx again Uten. Is there an easier way? This counts down mil secs, I tried multiplying by 1000 to get secs but still didnt work.... any1? Plz??...... Func Start() ToolTip("") Local $AllFieldEmpty = True For $I = 0 To UBound($CoordsField) - 1 If GUICtrlRead($CoordsField[$I]) <> "" Then $AllFieldEmpty = False Next If $AllFieldEmpty Then MsgBox(16, "Error", "Please enter Coordinates") Return EndIf For $I = 0 To $NumTimeFields - 1 $cf = GUICtrlRead($CoordsField[$I]) $hrs = GUICtrlRead($HourFields[$I]) $mins = GUICtrlRead($MinuteFields[$I]) $secs = GUICtrlRead($SecondFields[$I]) If $cf = "" Then ContinueLoop MouseClick("right", StringLeft($cf, StringInStr($cf, ",") - 1), StringTrimLeft($cf, StringInStr($cf, ","))) Sleep(3000) MouseClick("left", (StringLeft($cf, StringInStr($cf, ",") - 1) + $XSpot) , (StringTrimLeft($cf, StringInStr($cf, ",")) + $YSpot)) ToolTip("Now running number " & ($I + 1) & "....Waiting " & $hrs & " hours, " & $mins & " minutes, " & $secs & " seconds.", 210, 3) Sleep(($hrs * 3600000) + ($mins * 60000) + ($secs * 1000)) ; countdown Next MsgBox(48 + 0, "", "completed.") EndFunc Link to comment Share on other sites More sharing options...
NutherNoob Posted February 2, 2007 Author Share Posted February 2, 2007 Hmmm looks to be too hard........ Link to comment Share on other sites More sharing options...
Qsr Nrwn Posted February 2, 2007 Share Posted February 2, 2007 (edited) Hmmm looks to be too hard........Quite hard in fact... (By my side the only fact: Lack of programming skills?) I just have the same idea some time ago, but if you use AdLib to test, and as far as I understand it will pause your script, and get inaccurate time measuring, and the hard part will be that you have to create an event-handler for every control you want to set.If you make intensive use of loops - just try to keep it simple -, your script will get slower, and slower... and perhaps your computer will suffer from thatEDIT: By my side the only fact: Lack of programming skills? Means myself, not youSorry for any misunderstanding. English is not my mother tongue Edited February 2, 2007 by Qsr Nrwn Rev 127 Et factum et prælium magnum in cælo: Michaël et angeli ejus præliabantur cum dracone, et draco pugnabat, et angeli ejus: 8 et non valuerant, neque locus inventus est eorum amplius in cælo.9 Et projectus est draco ille magnus, serpens antiquus, qui vocatur diabolus, et Satanas, qui seducit universum orbem: et projectus est in terram, et angeli ejus cum illo missi sunt. Link to comment Share on other sites More sharing options...
Uten Posted February 2, 2007 Share Posted February 2, 2007 (edited) TO get a hour minute sec format you would have to calculate those. Again I have not tested it so you would have to verify that I remember the functions right and have not goofed in the calculations. Ex: $secT = Round($ms/1000, 0) ; We drop anything less than a second $Hour = ($secT - Mod($secT, 3600))/3600 ; Calculation how many hours it is in there. $MinT = ($secT -$Hour*3600) ; Total in minutes including rest $Min = ($MinT -Mod($MinT, 60))/60 ;should give a integer less than 60 BUT NOTE: CHECK if you could get 60 as a result. $Sec = $SecT - $Min*60 - $Hour*360 There might be better ways to do it. You could use API calls but I doubt the would be much faster. EDIT: Forgot autoit tags, looks much better with them. Edited February 2, 2007 by Uten Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
NutherNoob Posted February 3, 2007 Author Share Posted February 3, 2007 Ok, this is what I have come up with and is close to what I want BUT WHY, WHY, WHY cant I get the mins to display properly when hours are inputted?? Eg. I input 2 hours, 5 mins, 5 secs and get in the tooltip "2 hours, 165 mins, 5 secs". And also WHY, when it countsdown the tooltip stops at 1 and not 0?? Please help. expandcollapse popupFunc Start() ToolTip("") Local $AllFieldEmpty = True For $I = 0 To UBound($CoordsField) - 1 If GUICtrlRead($CoordsField[$I]) <> "" Then $AllFieldEmpty = False Next If $AllFieldEmpty Then MsgBox(16, "Error", "Please enter Coordinates") Return EndIf For $I = 0 To $NumTimeFields - 1 $cf = GUICtrlRead($CoordsField[$I]) $hrs = GUICtrlRead($HourFields[$I]) $mins = GUICtrlRead($MinuteFields[$I]) $secs = GUICtrlRead($SecondFields[$I]) $pausetime= ($hrs*3600)+($mins*60)+$secs If $cf = "" Then ContinueLoop MouseClick("right", StringLeft($cf, StringInStr($cf, ",") - 1), StringTrimLeft($cf, StringInStr($cf, ","))) Sleep(3000) MouseClick("left", (StringLeft($cf, StringInStr($cf, ",") - 1) + $XSpot) , (StringTrimLeft($cf, StringInStr($cf, ",")) + $YSpot)) While $pausetime > 0 $totalsecpause = INT($pausetime) $minpause = Int($totalsecpause/60) $hrspause= Int($totalsecpause/3600) $secpause = $totalsecpause - ($minpause*60) ToolTip("Now running number " & ($I + 1) & "....Waiting " & $hrspause & " hours, " & $minpause & " minutes, " & $secpause & " seconds.", 210, 3) Sleep(1000) $pausetime = $pausetime - 1 WEnd $pausetime = 0 Next MsgBox(48 + 0, "", "completed.") EndFunc ;Paste coords Func Paste() Send(ClipGet()) EndFunc ;==>Paste Func Terminate() Exit EndFunc ;==>Terminate Link to comment Share on other sites More sharing options...
Uten Posted February 4, 2007 Share Posted February 4, 2007 (edited) Does this look right to you?$totalsecpause = INT($pausetime) $minpause = Int($totalsecpause/60) $hrspause= Int($totalsecpause/3600) $secpause = $totalsecpause - ($minpause*60)oÝ÷ Ù*©àzÚºÚ"µÍÚ[H ÌÍÜ]Ù][YH ÝÏH EDIT: Added displaying 0 part. Edited February 4, 2007 by Uten Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
NutherNoob Posted February 4, 2007 Author Share Posted February 4, 2007 Does this look right to you?$totalsecpause = INT($pausetime) $minpause = Int($totalsecpause/60) $hrspause= Int($totalsecpause/3600) $secpause = $totalsecpause - ($minpause*60)oÝ÷ Ù*©àzÚºÚ"µÍÚ[H ÌÍÜ]Ù][YH ÝÏH EDIT: Added displaying 0 part.Uten mate, thankyou so much, working like a charm now :) One thing though, where should I put a "$GUI_EVENT_CLOSE" loop in this loop, in case someone wants to cancel the countdown? (I've made the button etc and works OUTSIDE of this loop) Thanx again Link to comment Share on other sites More sharing options...
Uten Posted February 4, 2007 Share Posted February 4, 2007 Depends on who the tool is for, but I tend to like to be able to cancel lengthy operations. You should also give the ability to minimize the progress dialog to the tray and if the window is minimized it should probably not pop up a tooltip every sec.. Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
Uten Posted February 5, 2007 Share Posted February 5, 2007 $secpause = $totalsecpause - ($hrspause*3600) - ($minpause*60) Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
NutherNoob Posted February 6, 2007 Author Share Posted February 6, 2007 $secpause = $totalsecpause - ($hrspause*3600) - ($minpause*60)oÝ÷ Ûú®¢× ØÂäyÖîµ§-¹©eÊz-Z§ém^»è§¦ëmyØë,zǯz¼)ຨ®Kw¢~Ø^¶)ÉmÖÀ*'z¯y©ò×±8Z®¶sbb33c¶'7W6SÒçBb33c·F÷FÇ6V7W6Ró3c¢b33c¶ÖçW6RÒçBb33c·F÷FÇ6V7W6RócÒb33c¶'7W6Róc·&ö&ÆVÒW&RÖ&Râââââ b33c·6V7W6RÒçBb33c·F÷FÇ6V7W6RÒb33c¶ÖçW6R£cÒb33c¶'7W6R£3c Link to comment Share on other sites More sharing options...
NutherNoob Posted February 6, 2007 Author Share Posted February 6, 2007 Thought it worked but actually not. When multiple hrs are inputted it messes everything up. Works fine if the time is < 1 hr...... Anyone have any ideas? Thanx $hrspause= Int($totalsecpause/3600) $minpause = Int(($totalsecpause/60) - $hrspause/60) ;problem here maybe..... $secpause = int($totalsecpause - ($minpause*60) - $hrspause*3600)Sorted!!!! :) 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