Sending keystrokes to Windows exe programs
rosuav at gmail.com
Sat Apr 2 21:52:39 CEST 2011
On Sun, Apr 3, 2011 at 2:48 AM, Alex van der Spek <zdoor at xs4all.nl> wrote:
> I can start a windows program on Vista with:
>>>> import subprocess
> Unfortunately sending keystrokes with communicate() does not appear to work:
> this does not produce any result but it does make IDLE become really idle.
I've just looked over the Python subprocess module. Is your subprocess
(named by the variable DVAname) one which takes key names on STDIN and
emits the appropriate keys?
dva.communicate('F2') will send the two-character string "F2" to the
STDIN of the process, and then wait for process termination. That's
why IDLE stops dead. If you want to send it a string and then keep
running, I think you want to use the stdin attribute:
More information about the Python-list