Jump to content

Repeated calls to ToolTip fail to clear data?


Recommended Posts

I meant to write a short quickie of a script to constantly show me the first five non-blank window titles in a WinList, using a ToolTip. The behavior has been strange. The text of the ToolTip appears not to clear with each iteration, so the message just gets longer and longer, running off the screen.

Here's the code:

HotKeySet("{ESC}", "_Quit")

Global $avWinList, $sMsg, $iCnt

While 1
    $avWinList = WinList()
    $sMsg = "Top 5 window titles"
    $iCnt = 0
    For $n = 1 To $avWinList[0][0]
        If $avWinList[$n][0] <> "" Then
            $iCnt += 1
            $sMsg &= @LF & $n & ":  " & $avWinList[$n][0]
            If $iCnt = 5 Then ExitLoop
        EndIf
    Next
    ToolTip("")
    ToolTip($sMsg, 100, 100)
    Sleep(1000)
WEnd

Func _Quit()
    Exit
EndFunc   ;==>_Quit

Here is what the output looks like:

I'm having trouble understanding why the ToolTip just gets longer and longer, when $sMsg gets reset in each iteration of the While/WEnd loop. The ToolTip("") was not in there originally, but was added in an attempt to clear the tip before resetting it. The behavior is the same with 3.2.10.0 and 3.2.11.1.

I would appreciate it if anyone else could test the code and tell me if they have the same issue (or if you see an error in the code that I'm missing).

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

its probably becose you cant clean tooltip before its created, so firststep is to create it and then cleane it

HotKeySet("{ESC}", "_Quit")

While 1
    $avWinList = WinList()
    $sMsg = "Top 5 window titles"
    $iCnt = "0"
    For $n = 1 To $avWinList[0][0]
        If $avWinList[$n][0] <> "" Then
            $iCnt += 1
            $sMsg &= @LF & $n & ":  " & $avWinList[$n][0]
            If $iCnt = 5 Then ExitLoop
        EndIf
    Next
    ToolTip($sMsg,100,100)
    Sleep(1000)
    ToolTip("")
WEnd

Func _Quit()
    Exit
EndFunc  ;==>_Quit

or

HotKeySet("{ESC}", "_Quit")

While 1
    ToolTip("STARTING",100,100)
    $avWinList = WinList()
    $sMsg = "Top 5 window titles"
    $iCnt = "0"
    For $n = 1 To $avWinList[0][0]
        If $avWinList[$n][0] <> "" Then
            $iCnt += 1
            $sMsg &= @LF & $n & ":  " & $avWinList[$n][0]
            If $iCnt = 5 Then ExitLoop
        EndIf
    Next
    ToolTip("")
    ToolTip($sMsg,100,100)
    Sleep(1000)
WEnd

Func _Quit()
    Exit
EndFunc  ;==>_Quit

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

Consider that tooltip is a window, and its title is the text. So when you do WinList, you get the text of your old tip added to your list. Kill old tooltip before WinList:

While 1
    ToolTip("")
    $avWinList = WinList()
    $sMsg = "Top 5 window titles"
    $iCnt = 0
    For $n = 1 To $avWinList[0][0]
        If $avWinList[$n][0] <> "" Then
            $iCnt += 1
            $sMsg &= @LF & $n & ":  " & $avWinList[$n][0]
            If $iCnt = 5 Then ExitLoop
        EndIf
    Next
    ToolTip($sMsg, 100, 100)
    Sleep(1000)
WEnd

"be smart, drink your wine"

Link to comment
Share on other sites

Consider that tooltip is a window, and its title is the text.

Well... rats! I totally didn't know that. And that fixed it. I never would have gotten there from the help file and parameters of the function Tooltip(), where the title is a separate parameter, and isn't even required (unless you want an icon):

The title, icon and Balloon Tip option all require Internet Explorer 5.0 or later in order to function.

To display an icon, you must specify a non-empty title. The icon appears on the same row as the title and thus requires a title to be present.

That doesn't give the impression that the text becomes the title (unless you provide one, presumably). Interestingly, providing a title doesn't fix it. Changing just this in the original still gives the same problem:

ToolTip($sMsg, 100, 100, "Tool Tip Title")

The "title" is just bolded text included as part of the "text" in the actual window's title! Confusing.

Thanks for the tip.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...