How to find a textbox?

  • Thread starter Thread starter Marc Fauser
  • Start date Start date
M

Marc Fauser

How can I find the textbox (handle?) e.g. from
http://www.microsoft.com/
on the right top corner from my program?
And how can I identify the textbox again, if
a new browser window is opened with the
same page? Both textboxes have different handles.
How can I recognize the same textbox?

Marc
 
Marc Fauser said:
How can I find the textbox (handle?) e.g. from
http://www.microsoft.com/
on the right top corner from my program?
huh?

And how can I identify the textbox again, if
a new browser window is opened with the
same page?

What are you talking about? Your program, or a web browser?
Both textboxes have different handles.
How can I recognize the same textbox?

Hard to say, could you be a little more vague?
 
Hard to say, could you be a little more vague?

Sorry.

I want to access a textbox inside the Internet Explorer
from my program. Like the search textbox from Google.

Marc
 
Marc,

* "Marc Fauser said:
Sorry.

I want to access a textbox inside the Internet Explorer
from my program. Like the search textbox from Google.

Did you have a look at the textbox using the Spy++ tool which comes with
VS.NET Professional or better? If you can access this window using
this tool, you may be able to access it through p/invoke on
'FindWindow', 'FindWindowEx', 'GetClassName', ...
 
Marc Fauser said:
I want to access a textbox inside the Internet Explorer
from my program. Like the search textbox from Google.


I agree with Wagner, I would use a tool like Spy ++ to determine the Class
Name & Handle of the child you are tying to find. Next, I would call
GetWindow(GW_HWNDFIRST) to get the first child, set up an infinite loop of
GetWindow(GW_HWNDNEXT), and then add a break-point or step into the code and
manually advance through each loop. Once you arrive at the Handle of the
window you are looking for, you can set a specific number of iterations to
find the child (ie. if it takes 5 loops to find the handle that you know is
good, then hard-code 5 into your infinite loop, making it not infinite
anymore).

However, this approach is *extremely* brittle, something even so minor as
changing the order of the toolbars will break your code. I would only use
this method in a closed environment, as a tool for my own personal use.

Another approach would be to find the /class name/ of the child you are
looking for- use FindWindow to find the Browser window, then make a loop
that uses GetWindow to iterate through every child, then use GetWindowClass
to get the actuall class name of the child.

This method is almost as bad as hard coding an index (as in the first
method), because if a new toolbar is added before the one that hosts your
text box, and the new toolbar also contains a text box with the same class
name (very possible), you will mistakenly get the wrong text box.

~
Jeremy
 
Back
Top