generation of keyboard events

R

RAM

Hi,

I need to start an external program and pass the keyboard events like
F1,Right arrow key etc to the program..I am trying to use the
subprocess module to invoke the external program. I am able to invoke
but not able to generate the keyboard events and pass them on to the
external progam. Please help me in this because I am a beginner.

regards
Sreerama V
 
E

Emile van Sebille

On 7/5/2009 8:56 AM RAM said...
Hi,

I need to start an external program and pass the keyboard events like
F1,Right arrow key etc to the program..I am trying to use the
subprocess module to invoke the external program. I am able to invoke
but not able to generate the keyboard events and pass them on to the
external progam.

If you're on *nix, search for python and expect and you'll find
something based apps -- I'm not sure what you do for GUIs. On windows,
I'm sure there are ways of doing this with the win32 extensions, but I
commonly use msched from www.mjtnet.com. I create msched scripts from
within python and use subprocess to invoke msched and execute the python
generated script.

HTH,

Emile
 
R

RAM

catb.org/esr/faqs/smart-questions.html

You have told us nothing about the environment where you are trying to
accomplish this.  GUI, CLI, Unix, Windows, etc? So I suggest that you
checkout the curses getch functions.  You can find them in the standard
library documentation athttp://docs.python.org.  You should also reference
documentation for the C version in your systems man pages.

Hi Tim,

I am trying to do this on windows. My program(executable) has been
written in VC++ and when I run this program, I need to click on one
button on the program GUI i,e just I am entering "Enter key" on the
key board. But this needs manual process. So i need to write a python
script which invokes my program and pass "Enter key" event to my
program so that it runs without manual intervention.

Thank in advance for the help.

regards
Sreerama V
 
S

Simon Brunning

2009/7/6 RAM said:
I am trying to do this on windows. My program(executable) has been
written in VC++ and when I run this program, I need to click on one
button on the program GUI i,e just I am entering "Enter key" on the
key board. But this needs manual process. So i need to write a python
script which invokes my program and pass "Enter key" event to my
program so that it runs without manual intervention.

Try <http://pywinauto.openqa.org/>.
 
T

Tim Harig

I am trying to do this on windows. My program(executable) has been
written in VC++ and when I run this program, I need to click on one
button on the program GUI i,e just I am entering "Enter key" on the
key board. But this needs manual process. So i need to write a python
script which invokes my program and pass "Enter key" event to my
program so that it runs without manual intervention.

This can be done using the WScript.WshShell.SendKeys() method when running
Python with Windows Scripting Host by using the .pyw extension:

http://msdn.microsoft.com/en-us/library/8c6yea83(VS.85).aspx
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top