Reputation: 3107
What i want to know is how can you give input to a GUI app that is closed source and does not have any public API.
To be more concise, let's say you open solitaire and want through a program to play it. Or, to go even to the basics, you have an GUI app with a button and you want to click it through another program.
I know the question is a little vague, but that's the best I can phrase it. Please help me with some edits or some comments to make it more specific.
Upvotes: 0
Views: 581
Reputation: 231
Assuming its an X11 app in Linux you could connect the process to one end of a named pipe and then echo X-Input events down the other end of the pipe.
Upvotes: 0
Reputation: 122001
Investigate SendInput()
. It can be used to simulate mouse movements and key presses.
To locate a Windows application using its GUI you can use EnumWindows()
to locate a Window with a particular title. This will provide a Window handle. To give that window focus, you could:
EnumWindows()
GetWindowRect()
to get the co-ordinates of the window rectangleSendInput()
and simulate a mouse click using SendInput()
I have done this once, and it is infuriatingly difficult to get right. Once you start your program sit on your hands: don't touch the mouse or the keyboard.
(I have no knowledge on how to do anything like this on Linux)
Upvotes: 1