Simulate input to another program

Discussion in 'Python' started by 31337one@gmail.com, Jul 27, 2006.

  1. Guest

    Hello everyone,

    I am using a python script as a way to test another program that I have
    written in C++. The program cannot be altered. It needs to stay the way
    it is.

    I need to simulate a few keystrokes to the application while it is
    running. The application uses number keys and y and n to navigate a
    basic menu.

    Is there a way within python to simulate the keystrokes to this other
    program.

    Both the application and the python script are running in a terminal.

    Thanks for all your help,

    -E
    , Jul 27, 2006
    #1
    1. Advertising

  2. TeCh Guest

    wrote:

    > I am using a python script as a way to test another program that I have
    > written in C++. The program cannot be altered. It needs to stay the way
    > it is.
    >
    > I need to simulate a few keystrokes to the application while it is
    > running. The application uses number keys and y and n to navigate a
    > basic menu.
    >
    > Is there a way within python to simulate the keystrokes to this other
    > program.


    I think this is possible with an expect module, such as
    http://pexpect.sourceforge.net/.

    <quote>
    Description: Python module for automating interactive applications
    Pexpect is a pure Python module for spawning child applications;
    controlling them; and responding to expected patterns in their
    output. Pexpect works like Don Libes' Expect. Pexpect allows your
    script to spawn a child application and control it as if a human were
    typing commands.
    </quote>

    --
    TeCh
    TeCh, Jul 27, 2006
    #2
    1. Advertising

  3. Guest

    So there is no easy built in way to do this?
    , Jul 27, 2006
    #3
  4. On 2006-07-27, <> wrote:
    > So there is no easy built in way to do this?


    Depends on what you mean by easy. A look at the pty module
    may help.

    --
    Antoon Pardon
    Antoon Pardon, Jul 27, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rey
    Replies:
    4
    Views:
    10,940
    Roedy Green
    Dec 12, 2003
  2. Replies:
    1
    Views:
    512
    Andrew Thompson
    Oct 31, 2005
  3. Replies:
    2
    Views:
    676
  4. Replies:
    12
    Views:
    600
    Jeff Higgins
    Jul 4, 2007
  5. Replies:
    2
    Views:
    362
    zentara
    May 6, 2008
Loading...

Share This Page