Jump to content
Sign in to follow this  

Windows System Tray Baloon Tip Text gets cut off

Recommended Posts


I am able to read systray applications baloon tips. I found some working code on the AutoIT forum.

The code below works fine and does exactly what i need.

The only problem i am experiencing is that the baloon text i am interested in, gets cut off. I want to be able to read the Microsoft Proquota.exe

Tooltip. Currently when i hover the mouse over the over the systray application is read the text: "Waarschuwing: de profielruimte is met 528880 KB overschreden" (in Dutch language).

With the code below i am able to retrieve the baloon text but it only returns: "Waarschuwing: de profielruimte is met 528".

So the last part of the text is cut off: "880 KB overschreden"

Is there any way i can retrieve the whole baloon text ?

#Include <GuiToolBar.au3>
#Include <GuiToolTip.au3>


Func GetToolText()

    Local $hTrayWnd, $hToolBar, $iToolCount, $n, $sToolText, $iToolCount

    ; Get handle to system tray
    $hTrayWnd = WinGetHandle("[CLASS:Shell_TrayWnd]")

    ; Get handle to sytem tray ToolBar
    $hToolBar = ControlGetHandle($hTrayWnd, "", "[CLASS:ToolbarWindow32;INSTANCE:1]")

    ; Get ToolTip handle for ToolBar
    $hToolTip = HWnd("0x" & Hex(_GUICtrlToolbar_GetToolTips($hToolBar), 8))
    ;ConsoleWrite("Debug: $hToolTip = " & $hToolTip & @LF)

    ; Get count of tools in ToolTip
    $iToolCount = _GUIToolTip_GetToolCount($hToolTip)
    ; ConsoleWrite("Debug: $iToolCount = " & $iToolCount & @LF)

    ; List text of all the tools in the ToolTip
    For $n = 0 To $iToolCount - 1
        $sToolText = _GUIToolTip_GetText($hToolTip, $hToolBar, $n)
        ConsoleWrite("Tool tips baloon text: " & $n & ":  " & $sToolText & @CRLF)
Edited by pluto41

Share this post

Link to post
Share on other sites

it's a long standing bug in _GUIToolTip_GetText()

from the time the Auto3Lib UDF was added to AutoIt

and changed from Ansi to Unicode

this line is the problem

_MemRead($tMemMap, $pText, $pBuffer, 81) ; should be 256 or MAX_PATH = 260


In Windows 2000 and later the tooltip length is limited to 128 characters.

Edit: typo

replace_GUIToolTip_GetText() with this:

Func __GUIToolTip_GetText($hWnd, $hTool, $iID)
    Local $tBuffer = DllStructCreate("wchar Text[260]")
    Local $pBuffer = DllStructGetPtr($tBuffer)
    Local $tToolInfo = DllStructCreate($tagTOOLINFO)
    Local $pToolInfo = DllStructGetPtr($tToolInfo)
    Local $iToolInfo = DllStructGetSize($tToolInfo)
    DllStructSetData($tToolInfo, "Size", $iToolInfo)
    DllStructSetData($tToolInfo, "hWnd", $hTool)
    DllStructSetData($tToolInfo, "ID", $iID)
    If _WinAPI_InProcess($hWnd, $_TT_ghTTLastWnd) Then
        DllStructSetData($tToolInfo, "Text", $pBuffer)
        _SendMessage($hWnd, $TTM_GETTEXTW, 0, $pToolInfo, 0, "wparam", "ptr")
        Local $tMemMap
        Local $pMemory = _MemInit($hWnd, $iToolInfo + 260, $tMemMap)
        Local $pText = $pMemory + $iToolInfo
        DllStructSetData($tToolInfo, "Text", $pText)
        _MemWrite($tMemMap, $pToolInfo, $pMemory, $iToolInfo)
        _SendMessage($hWnd, $TTM_GETTEXTW, 0, $pMemory, 0, "wparam", "ptr")
        _MemRead($tMemMap, $pText, $pBuffer, 260)
    Return DllStructGetData($tBuffer, "Text")
EndFunc   ;==>__GUIToolTip_GetText
Edited by rover

I see fascists...

Share this post

Link to post
Share on other sites


This adjustment to the function works very well. Thank you very much for your reply.

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.