Reading text from a Windows form
I would like, if not for some other reason, which is an academic exercise, to be able to read text written in a form in a Windows application. The program seems to be not written in .NET, but in .NET terms, I think you would describe the program as having a form with a label, and I would like to read the text from that label.
I believe I can see the text being written to the screen using the User32 function! TextOut (and in other areas User32! DrawString). However, it would be nice if I didn't have to intercept this function to get the information I am looking for, but instead, if I could just read it from the form directly.
So, given the window handle, is it possible to read the text that was written to that window with functions like TextOut and DrawString using some similar API or other clever means?
Or am I wrong about that? Should I just hook up the function and search for text in every call and pray?
Thanks!
a source to share
If the text is saved in a standard way in the control, you can use SendMessage
Win32.SendMessage(controlHandle, Win32.WM_GETTEXTLENGTH, 0, null);
If the control was written with security in mind, the text is almost certainly not saved in a format that can be requested through the Windows API.
I used the Snadboy Revelation program to grab forgotten passwords from programs (which just showed up as *****). Revelation uses the same technique. However, most modern programs hide the text of passwords and similar fields, so this is not so much these days.
UPDATE:
Found source code for Windows Spy app.
a source to share