Jump to content

Question about tooltips


Recommended Posts

Hi Guys,

I have a task to verify correctness tooltips text in application. (testing purpose) But I could not get the text of tooltips.

I found function _GUIToolTip_GetText($hWnd, $hTool, $iID), but I can not get $iID.

Piece of my code below:

Local $hWnd = WinGetHandle($wnd[$IDX_WND_NAME],$wnd[$IDX_WND_TEXT]) ; working properly

Local $hToolbar = ControlGetHandle($wnd[$IDX_WND_NAME],$wnd[$IDX_WND_TEXT],"[CLASS:msvb_lib_toolbar;INSTANCE:5]") ; working properly

Local $hTooltips = _GUICtrlToolbar_GetToolTips($hToolbar) ; working properly

Local $TextToolTip = _GUIToolTip_GetText($toolTips, $hWnd, $iID) ; I do not know how to get 3-d parameter $iID (I tried Index of tooltips element $iID = [0..6] (I have 7 tooltips and 7 toolbars elements) - but it does not work )

in the end of this script TextToolTip="" (empty string)

Could anybody help me to get the tooltips text. Thanks in advance.

Link to comment
Share on other sites

Hi Guys,

I have a task to verify correctness tooltips text in application. (testing purpose) But I could not get the text of tooltips.

I found function _GUIToolTip_GetText($hWnd, $hTool, $iID), but I can not get $iID.

Piece of my code below:

Local $hWnd = WinGetHandle($wnd[$IDX_WND_NAME],$wnd[$IDX_WND_TEXT]) ; working properly

Local $hToolbar = ControlGetHandle($wnd[$IDX_WND_NAME],$wnd[$IDX_WND_TEXT],"[CLASS:msvb_lib_toolbar;INSTANCE:5]") ; working properly

Local $hTooltips = _GUICtrlToolbar_GetToolTips($hToolbar) ; working properly

Local $TextToolTip = _GUIToolTip_GetText($toolTips, $hWnd, $iID) ; I do not know how to get 3-d parameter $iID (I tried Index of tooltips element $iID = [0..6] (I have 7 tooltips and 7 toolbars elements) - but it does not work )

in the end of this script TextToolTip="" (empty string)

Could anybody help me to get the tooltips text. Thanks in advance.

I think the $ID is the id you used when you created the toolbar component as in

_GUICtrlToolbar_AddButton ($hToolbar, $ID, $STD_FILENEW)

So if the first id you used was 1000 then the id's are 1000, 1001,1002,.. 1007

I haven't tried it the way you showed so I could be wrong.

You can read the text of a displayed tooltip, so for your testing you could move the mouse over the control and check that the tooltip text is correct.

#include <array.au3>
#include <windowsconstants.au3>

$lastList = ''
$gui = GUICreate("test tool tip reading")
$but1 = GUICtrlCreateButton("sample button",50,50,120,22)
GUICtrlSetTip(-1,"this is the tooltip for $But1")
$but2 = GUICtrlCreateButton("Another one",50,150,120,22)
GUICtrlSetTip(-1,"Tooltip for $but2, but try controls in any other app too.")
GUISetState()
While GUIGetMsg() <> -3
    
    $List = ''
    $wl = WinList("[class:tooltips_class32]");get all th etooltips

    For $n = 1 To $wl[0][0]
        If BitAND(WinGetState($wl[$n][1]), 2) Then;if visible
            $List &= WinGetTitle($wl[$n][1]) & '; '; read the title, which for a tooltip is the text
        EndIf
    Next
        If $List <> $lastList And $List <> '' Then
            ConsoleWrite($List & "Previous = " & $lastlist & @CRLF)
            $lastList = $List
        EndIf

WEnd
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I think the $ID is the id you used when you created the toolbar component as in

_GUICtrlToolbar_AddButton ($hToolbar, $ID, $STD_FILENEW)

So if the first id you used was 1000 then the id's are 1000, 1001,1002,.. 1007

I haven't tried it the way you showed so I could be wrong.

You can read the text of a displayed tooltip, so for your testing you could move the mouse over the control and check that the tooltip text is correct.

#include <array.au3>
#include <windowsconstants.au3>

$lastList = ''
$gui = GUICreate("test tool tip reading")
$but1 = GUICtrlCreateButton("sample button",50,50,120,22)
GUICtrlSetTip(-1,"this is the tooltip for $But1")
$but2 = GUICtrlCreateButton("Another one",50,150,120,22)
GUICtrlSetTip(-1,"Tooltip for $but2, but try controls in any other app too.")
GUISetState()
While GUIGetMsg() <> -3
    
    $List = ''
    $wl = WinList("[class:tooltips_class32]");get all th etooltips

    For $n = 1 To $wl[0][0]
        If BitAND(WinGetState($wl[$n][1]), 2) Then;if visible
            $List &= WinGetTitle($wl[$n][1]) & '; '; read the title, which for a tooltip is the text
        EndIf
    Next
        If $List <> $lastList And $List <> '' Then
            ConsoleWrite($List & "Previous = " & $lastlist & @CRLF)
            $lastList = $List
        EndIf

WEnd

- Thank you very much for your answer. Your code is very helpful for growing my experience in AutoIT Your code is working properly in many applications. But in my case it does not work :P (may be in my application used other class for tooltips)

- "I think the $ID is the id you used when you created the toolbar component as in"..... I am not a developer of this application. I just test this application and I know that GUI of this app developed on Visual Basic.

- I can not understand why _GUIToolTip_GetTitleText and _GUIToolTip_GetText do not work but _GUIToolTip_GetToolCount and _GUIToolTip_ToolExists work properly :P

Link to comment
Share on other sites

- Thank you very much for your answer. Your code is very helpful for growing my experience in AutoIT Your code is working properly in many applications. But in my case it does not work :P (may be in my application used other class for tooltips)

- "I think the $ID is the id you used when you created the toolbar component as in"..... I am not a developer of this application. I just test this application and I know that GUI of this app developed on Visual Basic.

- I can not understand why _GUIToolTip_GetTitleText and _GUIToolTip_GetText do not work but _GUIToolTip_GetToolCount and _GUIToolTip_ToolExists work properly :P

I would try running the application and use AutoIt Window Info to see if you can get the IDs of the components you want to know about. After that I don't have any more ideas apart from finding the class name of the tooltips.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • Moderators

Chances are these are owner drawn. You're not going to get that data the conventional way if they are.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I would try running the application and use AutoIt Window Info to see if you can get the IDs of the components you want to know about. After that I don't have any more ideas apart from finding the class name of the tooltips.

Thank you for your participation.

I did not find the way how to use AutoIt Window Info for tooltips. Tooltips appear below the mouse

Link to comment
Share on other sites

Thank you for your participation.

I did not find the way how to use AutoIt Window Info for tooltips. Tooltips appear below the mouse

I didn't mean use AutoIt WIndow info for the tooltips, but for the controls in the tool bar. If you can get the ids that way then your original approach might work.

Getting the class name for the tooltips is a bit more difficult. I found the class name for tooltips with a little script I've got somewhere, though searching would probably have been quicker.

If as, as SmOke_N warns, they are owner drawn and then it could be very difficult.(Meaning I don't know how.)

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...