Let me clarify the question a bit. I am talking about windows GUI programs. Say a program-window has a dialog box (or a confirm button) asking user input. How can I provide input to that program using my program (written in say C#, Java or Python). Or say, a program window is showing some image in one of its panels. How can I grab that from other(my) program. It is a kind of impersonating (or inter-win-program messaging?). Someone told me it can be done using spy++. But how? Can you explain? What code to write? What to do with spy++? Provide an example please. If this question is a dupe provide me links. Thanks.
views:
81answers:
3To programmatically generate key presses, see http://stackoverflow.com/questions/136734/key-presses-in-python, and search for "generate", "key", "emulate", "fake".
To programmatically capture the screen, see http://stackoverflow.com/questions/1163761/c-capture-screenshot-of-active-window, and search for terms like "capture", "window", "screen".
spy++ is listening for all win32 messages. It is very useful for debugging an application but I don't think that it is a good idea to use it as an inter-process communication mechanism.
You can use win32 apis to send input to your program. As an example, You can modify the content of an edit text by using the SetWindowText function.
You need to get the handle of the window. You can use the FindWindow and the GetDlgItem to get it.
It will work for c++ and python thanks to win32 python extension. I don't know if there it is possible to use win32 api from java.
If you want to write win32 code to do it, start here:
http://msdn.microsoft.com/en-us/library/ms632589(VS.85).aspx
If you just want to hook the gui as easily as possible, investigate: