473,320 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Simulate input to another program

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 '06 #1
3 2607
31******@gmail.com 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
Jul 27 '06 #2
So there is no easy built in way to do this?

Jul 27 '06 #3
On 2006-07-27, 31******@gmail.com <31******@gmail.comwrote:
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
Jul 27 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Michael J Whitmore | last post by:
Greetings, I have a very simple question. How do you simulate a user input to turn off a screen saver in Windows (either a mouse movement, mouse click, or keyboard input)? I promise I searched...
5
by: Jean-Pierre Bergamin | last post by:
Dear python-Community We are forced to use a quite old simulation software that's based on Modula-2. The idea is now to let this software "talk" to the outside world over a TCP/IP network. ...
2
by: Christian | last post by:
Hello, As the subject says it, is there a way to simulate a special keypress in JS ? In my case, on loading an HTML page, i'd like to set the cursor at the end of the input text of an <input...
10
by: JustSomeGuy | last post by:
I need to log into a web page automatically. The web page has a password text field and a login button. (A form?) How do I simulate that a user logged in and entered the password and pressed...
2
by: dast | last post by:
I want to simulate an input and post into a web page and than download the web page that is opened after the correct input! The web page exists of an user input form with userid and password, after...
61
by: /* frank */ | last post by:
I have to do a homework: make a CPU simulator using C language. I have a set of asm instructions so I have to write a program that should: - load .asm file - view .asm file - do a step by step...
1
by: TK | last post by:
I have a file upload control to allow a user to select/upload a file to the server. They need to upload x number of files in one shot because they have to confirm that they are uploading x number...
2
by: Eli | last post by:
HI! I made some quiz using one HTML form (few question with few radio-button each like potential answers) that have one Submit button. I would like to simulate click on this button (e.g. named...
3
by: John Dalberg | last post by:
I have an app that keeps popping up a windows with a 'Yes' or 'OK' button on it. I am trying to write a little app that automates hitting the enter key so I don't have to do it myself. I used...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.