I am opening a process (with os.popen() ) that, for some commands, detects certain keypresses (e.g. ESC - not the character, the key). Is there a way to send keypress events to the process?
A:
The obvious way would be to start the process in it's own shell.
something like os.popen("sh command")
Martin Beckett
2008-11-10 22:46:59
+1
A:
You probably want something like Pexpect
. It's been around a while, and there may be a better alternative, now, but it will let you do what you want.
As far as I know, there is no easy way to do that kind of thing with os.popen or the commands in the subprocess
module.
fivebells
2008-11-10 22:52:35
A:
What platform is this on?
You may have to actually feed events into the event loop, if it's running on Win32.
Tony Arkles
2008-11-11 00:04:58