Function Reference


_GUIToolTip_HitTest

Retrieves the information that a ToolTip control maintains about a tool

#include <GuiToolTip.au3>
_GUIToolTip_HitTest ( $hTool, $hWnd, $iX, $iY )

Parameters

$hTool Handle to the ToolTip control (returned by _GUIToolTip_Create.)
$hWnd Handle to the window that contains the tool
$iX X position to test
$iY Y position to test

Return Value

Success: an array with the following format:
[0] - Flags that control the tooltip display. This member can be a combination of the following values:
    $TTF_IDISHWND = Indicates that $iID is the window handle to the tool instead of the ID
    $TTF_CENTERTIP = Centers the window below the tool specified by $iID
    $TTF_RTLREADING = Indicates that text will be displayed in the opposite direction
    $TTF_SUBCLASS = Indicates that the control should subclass the tool's window to intercept messages
    $TTF_TRACK = Positions the control next to the tool to which it corresponds
    $TTF_ABSOLUTE = Positions the window at the same coordinates provided by TTM_TRACKPOSITION
    $TTF_TRANSPARENT = Causes the control to forward mouse messages to the parent window
    $TTF_PARSELINKS = Indicates that links in the control text should be parsed
[1] - Handle to the window that contains the tool
[2] - Identifier of the tool
[3] - X coordinate of the upper left corner of the rectangle
[4] - Y coordinate of the upper left corner of the rectangle
[5] - X coordinate of the lower right corner of the rectangle
[6] - Y coordinate of the lower right corner of the rectangle
[7] - Handle to the instance that contains the string resource for the tool
[8] - Text for the tool
[9] - Application-defined value associated with the tool
Failure: set @error (see remark)

Remarks

If $hWnd referenced control is not in the same process and both processes run in different AutoIt mode (@AutoItVersion), the @error is set to 6.

This message can only be used when the tool has the $TTF_TRACK flag set. _GUIToolTip_HitTest() will fail if $TTF_TRACK is not set, regardless if the hit point is in the tools rectangle or not.
The Flags can be converted in a readable string with _GUIToolTip_BitsToTTF().

Related

_GUIToolTip_BitsToTTF

Example

Example 1

#include "Extras\HelpFileInternals.au3"

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIIcons.au3>

Global $g_hToolTip, $g_aPos, $g_hButton

; Press g to display the current tooltip information.
HotKeySet("g", "GetInfo")

Example()

Func Example()
    Local $hGUI = GUICreate("ToolTip Hit Test v(" & @AutoItVersion & ")", 450, 300, 100, 100)

    $g_hToolTip = _GUIToolTip_Create(0, $TTS_CLOSE + $TTS_BALLOON)
    _MemoSetHandleInProcess($g_hToolTip)

    Local $idButton = GUICtrlCreateButton("Button ToolTip", 30, 32, 130, 28)
    $g_hButton = GUICtrlGetHandle($idButton)

;~  $hGUI = 0 ; is OK
    _GUIToolTip_AddTool($g_hToolTip, $hGUI, "X: " & @TAB & " Y: " & @TAB, $g_hButton)

    Local $hIcon = _WinAPI_LoadShell32Icon(15)

    _GUIToolTip_SetTitle($g_hToolTip, 'Title', $hIcon)

    GUISetState(@SW_SHOW)

    ; Show the tooltip associated with the button
    Opt("MouseCoordMode", 2)
    MouseMove(50, 42, 0)
    Sleep(250)

    $g_aPos = MouseGetPos()
    _GUIToolTip_TrackPosition($g_hToolTip, $g_aPos[0] + 10, $g_aPos[1] + 20)
    _GUIToolTip_TrackActivate($g_hToolTip, True, $hGUI, $g_hButton)
    _GUIToolTip_UpdateTipText($g_hToolTip, $hGUI, $g_hButton, "X: " & $g_aPos[0] & " Y: " & $g_aPos[1])

    GetInfo()

    While 1
        Sleep(100)
        $g_aPos = MouseGetPos()
        _GUIToolTip_TrackPosition($g_hToolTip, $g_aPos[0] + 10, $g_aPos[1] + 20)
        _GUIToolTip_UpdateTipText($g_hToolTip, $hGUI, $g_hButton, "X: " & $g_aPos[0] & " Y: " & $g_aPos[1])
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd

    _MemoResetHandleInProcess($g_hToolTip)
    _GUIToolTip_Destroy($g_hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example

Func GetInfo()
    Local $aTool = _GUIToolTip_HitTest($g_hToolTip, $g_hButton, $g_aPos[0], $g_aPos[1])
    _MemoMsgBox($MB_SYSTEMMODAL, "Tooltip info", "Flags: " & @TAB & _GUIToolTip_BitsToTTF($aTool[0]) & @CRLF & _
            "HWnd: " & @TAB & $aTool[1] & @CRLF & _
            "ID: " & @TAB & "0x" & $aTool[2] & @CRLF & _
            "Left X:" & @TAB & $aTool[3] & @CRLF & _
            "Left Y:" & @TAB & $aTool[4] & @CRLF & _
            "Right X:" & @TAB & $aTool[5] & @CRLF & _
            "Right Y:" & @TAB & $aTool[6] & @CRLF & _
            "Instance:" & @TAB & $aTool[7] & @CRLF & _
            "Text:" & @TAB & $aTool[8] & @CRLF & _
            "lParam:" & @TAB & $aTool[9])
EndFunc   ;==>GetInfo

Example 2 : ToolTip Hit Test to an External process

#include "Extras\HelpFileInternals.au3"

#include <GUIToolTip.au3>

Example()

Func Example()
    Local $sFromTo
    Local $hWin = _MemoRunAU3OutProcess($sFromTo, True) ; OK same mode, KO if different mode
    Local $hButton = _MemoCreateOutProcess($hWin, "Button", 1, $sFromTo)

    Local $hToolTip = _MemoGetHandleInProcess()

    Local $aPos = MouseGetPos()

    Local $aTool = _GUIToolTip_HitTest($hToolTip, $hButton, $aPos[0], $aPos[1])
    If @error Then
        _MemoMsgBox($MB_ICONERROR, "Info" & $sFromTo, "_GUIToolTip_HitTest()" & " @error = " & @error & @CRLF & _
                @TAB & "cannot be accessed from an external process" & @CRLF & _
                @TAB & "running in different mode")
    Else
        ; only working if both processes are running in "same mode"
        _MemoWrite("<<< Tooltip info" & $sFromTo & @CRLF & _
                "Flags: " & @TAB & _GUIToolTip_BitsToTTF($aTool[0]) & @CRLF & _
                "HWnd: " & @TAB & "0x" & Hex($aTool[1]) & @CRLF & _
                "ID: " & @TAB & "0x" & Hex($aTool[2]) & @CRLF & _
                "Left X:" & @TAB & @TAB & $aTool[3] & @CRLF & _
                "Left Y:" & @TAB & @TAB & $aTool[4] & @CRLF & _
                "Right X:" & @TAB & $aTool[5] & @CRLF & _
                "Right Y:" & @TAB & $aTool[6] & @CRLF & _
                "Instance:" & @TAB & $aTool[7] & @CRLF & _
                "Text:" & @TAB & $aTool[8] & @CRLF & _
                "lParam:" & @TAB & $aTool[9])
    EndIf

    _MemoMsgBoxStatus("", Default, $hWin) ; no more action, wait GUI for closing, close also OutProcess GUI

EndFunc   ;==>Example