Jump to content

  • Log In with Google      Sign In   
  • Create Account

Having a program send input to another program


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 SonicD007   Members   -  Reputation: 464

Like
0Likes
Like

Posted 01 May 2011 - 10:37 AM

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!

Sponsor:

#2 nfries88   Members   -  Reputation: 259

Like
1Likes
Like

Posted 01 May 2011 - 04:33 PM

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.
Looking for paid or open-source C++ programming work. Been programming since 2005. No degree.

#3 rip-off   Moderators   -  Reputation: 8726

Like
0Likes
Like

Posted 01 May 2011 - 04:42 PM

Using standard windows APIs, such as FindWindow() and SendMessage().

#4 SonicD007   Members   -  Reputation: 464

Like
0Likes
Like

Posted 01 May 2011 - 05:08 PM

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



#5 SimonForsman   Crossbones+   -  Reputation: 6305

Like
0Likes
Like

Posted 01 May 2011 - 05:59 PM

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)
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!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS