Sign in to follow this  
Followers 0
NutherNoob

Tooltip Loop

15 posts in this topic

#1 ·  Posted (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 by NutherNoob

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by Uten

Share this post


Link to post
Share on other sites

Holly molly, quite some long (unreadable) lines of code you have there..:D

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 :) )

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Hmmm looks to be too hard........

Share this post


Link to post
Share on other sites

#7 ·  Posted (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 that

EDIT: By my side the only fact: Lack of programming skills? Means myself, not you

Sorry for any misunderstanding. English is not my mother tongue

Edited 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.

Share this post


Link to post
Share on other sites

#8 ·  Posted (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 by Uten

Share this post


Link to post
Share on other sites

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.

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])
        $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

Share this post


Link to post
Share on other sites

#10 ·  Posted (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 by Uten

Share this post


Link to post
Share on other sites

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 :whistle::):)

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

Share this post


Link to post
Share on other sites

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..:whistle:

Share this post


Link to post
Share on other sites
$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

Share this post


Link to post
Share on other sites

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!!!! :whistle::):):)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0