Is there anyway of reading the contents of an external applicaiton's window?
Maybe it's just a problem with the application whose window I wish to read (because it is some kind of 'secure' telnet application), but even using the SPY++ program with MS Visual Dev Studio I have been unable to find any kind of messages that seem to be printing/displaying text in that window.
None of the WM_ or the EM_ messages have proved at all useful in this matter.
Any other suggestions?
::GetWindowText() can be used to get the title of the parent, pop-up and child windows or the text from a control such as a button or edit control. But you have to get a handle to the appropriate control on the external application.
I'm very grateful for your replies there people, but I'm affraid to say it hasn't helped enormously.
You see GetWindowText() (as shree correctly pointed out) only gets the title bar text of a window. I require the actuall text being displayed INSIDE the window.
The window in question is definitely not a control (hense the reason this function fails in getting its text)
Also the window of the application was not created from the standard "edit" class (which would have made thing much simpler) but rather of class "Afx:400000:b:10009:0:0" - which I presume is a custom defined class (defined by the people who wrote the application)
I'd be grateful for any other suggestion you can think of for getting access to this text.
Window handles are not a problem, this much I can do.
Unfortunately there isn't much you can do to get the window text. The tried and true method is by GetWindowText. If that doesn't work, well then the window procedure doesn't provide the option to get text via the WM_GETTEXT. Since it is a custom class there is really no way to determine how to get the text. Since it's in another process, you can't just pass a pointer to your buffer and send a million WM_USER+x messages and see if one works. Your best bet would be to contact whoever wrote the software and see if they have the appropriate documentation you need to get the text.
Well, I don't know if it is viable for you but if I were you and were stuck like this on a project I was working on for months, it wouldn't be a difficult task to write a basic OCR (the font would already be known) and read the text off the snapshot of the screen.
hmmm, the trouble is this program is supposed to be a quick 'in the background, hardly even know it's there' kind of program. doing a print screen and then running a search thread every second or so to find out if the required text is there is a little on the unpractical side.
I'd be very grateful for any other suggestions you might have though.