Reputation: 3389
Specifically, a program is running and I want to extract the text from a text box inside the program.
Generally, what methods/topics should I be using to "get inside" another .exe running on my system and extract data from a text box inside it using C++?
I just want a pointer towards the way in which I might achieve this. Thanks.
Upvotes: 2
Views: 1548
Reputation:
See How I Built a Working Online Poker Bot: Extracting Text from 3rd-Party Applications for an explanation of the inject-and-subclass techniques mentioned by @DeusAduro as well as a couple other techniques for the same, such as hooking the GDI text-output APIs. And of course if it's a standard textbox you can always send a WM_GETTEXT this works even across process boundaries (was designed to work across process boundaries in fact).
Upvotes: 0
Reputation: 6076
Another common technique for 'getting inside' a GUI application (windows specific) is DLL Injection + Windows Subclassing. This is probably considered somewhat advanced windows programming an excellent Book on the subject is 'Windows Via C/C++'. A brief idea of what this about is essentially:
Also note that nothing I have mentioned above is in any way 'hacking windows' this is a well defined behavior which was implemented purposely by Microsoft. Its quite well documented over on MSDN actually.
If you want to do this have a look at 'Windows Subclassing' and 'Setting Hooks'.
Upvotes: 4
Reputation: 67368
You can simply use EnumChildWindows
and SendMessage
withWM_GETTEXT
to the specific window you want to get the text from.
Upvotes: 4