Having a program send input to another program

Started by
3 comments, last by SimonForsman 12 years, 11 months ago
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!
Advertisement
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.
Using standard windows APIs, such as FindWindow() and SendMessage().
Thank you. What about for an os other than windows? Whats the linux equivalent of that?


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!

This topic is closed to new replies.

Advertisement