Jump to content

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>

GetToolText()

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)
    Next
EndFunc
Edited by pluto41
Link to comment
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

TraySetToolTip()

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")
    Else
        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)
        _MemFree($tMemMap)
    EndIf
    Return DllStructGetData($tBuffer, "Text")
EndFunc   ;==>__GUIToolTip_GetText
Edited by rover

I see fascists...

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