From: Matthew Herbert on 9 Oct 2009 16:46
Has anyone ever tried to get the tooltip text from a third party
application's button? (I'm working with an application called "Research
Wizard," but the code works just as well for Internet Explorer). I'm willing
to post the code (which is rather lengthy) if someone feels they can help
(but please read on to see if you think that you should reply to this post).
[Besides, this post is rather lengthy to begin with, even without the code.]
I am able to do the following (with help from a number of other posts):
- Enumerate the windows to get the target window handle
- Get the toolbar handle from the window handle
- Count the number of buttons on the toolbar (for looping purposes)
- Loop through each button
- Click each button
Despite being able to click the button, I can't seem to get the tooltip text
for the button.
To give you an idea of some of the APIs involved, I'm using the following:
Here are some of the SendMessage wMsg arguments I'm using:
TTM_ENUMTOOLS (trying to get this to work properly)
TTM_GETTEXT (trying to get this to work properly)
I found a post that suggests sending TTM_ENUMTOOLS with a pointer to the
TOOLINFO structure (Type TOOLINFO...End Type) and then passing TOOLINFO with
TTM_GETTEXT to get lpszText. The post also mentioned that memory needs to be
allocated that both processes can access. (Unfortunately, the post didn't
provide any syntax, just the concept written down). I have been unsuccessful
in this getting lpszText from TOOLINFO (despite being able to get
TBBUTTON.idCommand or TBBUTTON.iString when sending TB_GETBUTTON). (Maybe
the toolbar class I'm working with doesn't provide information for TOOLINFO).
As an aside: This code (and the concept behind it) is completely new to me,
and I've had to do a lot of learning along the way. There is a lot of
information that I'm still picking up.
Let me know if you can help.