Any way to capture text in a textbox inside another application?

  • Thread starter Thread starter Andy Chau
  • Start date Start date
A

Andy Chau

I need to write an application and need to find a way to "spy" on a textbox
in another application.
It will work the similar to the spy++ where you indicate that you want to
spy on a control in another app,
and the program will let you pick the control to spy on. From that point on,
all the messages sent to the control
will be routed to this program.

I am wondering how spy++ does that and is there any sample in MSDN shows how
to do that?

Thanks

Andy
 
Look at the SendMessage API function (WM_GETTEXT). This is provided that you
know the window handle of the control. You can get this by using FindWindow
(and using the caption of the form) and EnumChildWindows to enumerate the
children controls.

You may also be able to hook the application's message stream and listen
directly for messages sent to that control like WM_SETTEXT, but I haven't
tried this from a different process or from .NET.

VB6 used SetWindowLong to inject a module level function into the message
queue of a given window. At that point you can listen to all messages
destined for that handle.

HTH,
Eric Cadwell
http://www.origincontrols.com
 
Back
Top