Thread: Sending key input to another process

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    11

    Sending key input to another process

    I was just wondering if it is possible for one console-based program to send keyboard input to another console-based program. For example, is there any way to write to another process's stdin?

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    To both questions, the answer it yes, it is possible.
    How is determined by the operating system.
    On Windows, you can open a process via CreateProcess and at the same time redirected their standard input/output and in that way write data.
    Another way is using the SendInput API.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,732
    Well YES, you can, you just need to pipe the inputed chars from Process1 to Process 2. The concept you should be looked at here is called pipes. There some system calls which you need to call. Strictly speaking this concept is called Inter Process Communication (IPC's). There are different methods of achieving it. Have look this tutorial. Inter Process Communication Concept

    ssharish

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I would love some input on my BST tree.
    By StevenGarcia in forum C++ Programming
    Replies: 4
    Last Post: 01-15-2007, 01:22 AM
  2. sending input
    By X PaYnE X in forum Windows Programming
    Replies: 0
    Last Post: 06-08-2005, 12:11 PM
  3. Process sending file descriptors to another process
    By Yasir_Malik in forum C Programming
    Replies: 4
    Last Post: 04-07-2005, 07:36 PM
  4. key input definition
    By hkmixxa in forum C++ Programming
    Replies: 3
    Last Post: 08-09-2004, 05:39 PM
  5. single key input
    By SPiRiToFCaT in forum C++ Programming
    Replies: 14
    Last Post: 11-15-2002, 02:23 PM