Jump to content
Sign in to follow this  
jdelaney

Getting Text value of a ToolTip

Recommended Posts

jdelaney

I have an array of button handles for a windows based app, and I'm trying to get the ToolTip information so I may identify them (I'd rather not use hard coded references, we have lots of user rights and configurations). I thought the ToolTip info text would be best to do this, but can't get the _GUIToolTip* functions to work.

#include <GuiToolbar.au3>
#include <GuiButton.au3>
#include <Array.au3>

 opt ( "MouseCoordMode", 2 )

For $i = 0 to UBound ( $asControlCollection ) - 1
$GetText = _GUICtrlButton_GetText  ( $asControlCollection[$i][0] )
$GetTMar = _GUICtrlButton_GetTextMargin ( $asControlCollection[$i][0] )
$GetNote = _GUICtrlButton_GetNote  ( $asControlCollection[$i][0] )

 
MouseMove ( $asControlCollection[$i][1] + 5, $asControlCollection[$i][2] + 5)
sleep ( 3000 )_

GUIToolTip_Activate  ( $asControlCollection[$i][0], True )
$asTest2 = _GUIToolTip_GetCurrentTool  ( $asControlCollection[$i][0] )

_ArrayDisplay ( $asTest2 )
msgbox ( 4096, "test", "GetText=[" & $GetText & "]; GetTextMargin=[" & $GetTMar & "]; GetNote=[" & $GetNote & "]." )
Next

The array that is returned is always filled out with "0" for each of the levels.

I added a mouse over, and I'm able to view to tooltip, but still not able to record it.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
jdelaney

and, solved:

lainline,

It becomes a bit more complicated if you want to read the tips of another application. Take a look at this:

#include <WindowsConstants.au3>
#include <GuiToolTip.au3>

HotKeySet("{F1}", "_Read_Tip")
HotKeySet("{ESC}", "On_Exit")

; Choose your app
Global $sTitle = "[CLASS:WordPadClass]"
WinWaitActive($sTitle, "", 10)
; Get PID of your app
Global $iPID = WinGetProcess($sTitle)

; Keep the script running
While 1

Sleep(10)

WEnd

Func _Read_Tip()

; Get list of tooltips
Local $aTipList = WinList("[CLASS:tooltips_class32]")
; See which belong to your app
For $i = 1 To $aTipList[0][0]
If WinGetProcess($aTipList[$i][1]) = $iPID Then
; See which one is active
Local $aRet = _GUIToolTip_GetCurrentTool($aTipList[$i][1])
; If one is active then display it
If $aRet[8] <> "" Then MsgBox(0, "Visible Tip", $aRet[8])
EndIf
Next

EndFunc

Func On_Exit()

Exit

EndFunc

You have 10 seconds to get WordPad active after starting the script. Then every time you press F1 and there is an active Tooltip you will get a MsgBox with the text. Press ESC to exit the script.

I hope that is what you want. :oops:

M23

I modified it a bit, to work with my loop.


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
Melba23

jdelaney,

I had forgotten all about that! :bye:

Glad I could help - even though I did not. :oops:

M23

  • Like 1

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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  

×