Skip to main content
GameDev.net gamedev.net
🔒 Locked

Having a program send input to another program

Started by SonicD007 May 1, 2011 at 4:37 PM 3 replies 2k views
Original Post
SonicD007
SonicD007
Just wondering how programs send input to other programs, like EZ macro. Is it a windows hook doing this or what? It would be interesting if I could make a program automatically type "Hello World!" into notepad instead of a console screen/gui. Any links to tutorials on how to do this or what knowledge is required would be great. Thanks!
nfries88
nfries88
You can have application A replace stdin with a pipe which application B uses for stdout. In this way, the output of application B acts as the input for application A.
You can also use a normal file for stdin, but this is more limiting.
EDIT: You can use a file for stdin, stdout, and stderr. stdin = fopen("myinput.txt", "rt"); is how that'd work.

I'm not sure if it would work the same on Windows, but it's worth investigation.
rip-off
rip-off
Using standard windows APIs, such as FindWindow() and SendMessage().
SonicD007
SonicD007
Thank you. What about for an os other than windows? Whats the linux equivalent of that?

SimonForsman
SimonForsman

Thank you. What about for an os other than windows? Whats the linux equivalent of that?



If you're using X11 you can use the
XSendEvent function to send events to any window.

XDefaultRootWindow gets you the root window for your display
XQueryTree lets you obtain the child windows of a given window (start from the root and work your way down the tree to get a complete list of windows)
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.