[python-win32] Re: Emulate a keystroke for Kbhit function (Conio.h)

Roger Upole rwupole at msn.com
Wed Apr 11 08:30:54 CEST 2007


Frank Günther wrote:
> Hi All,
>
> I've automated a console application using win32pipe.popen2 by capturing the
> output stream and writing the input stream. So far it works fine but the
> console application uses Kbhit() from conio.h in some cases. Is there a
> possibility to fill the keyboard buffer and emulate a keystroke for the
> process opened by win32pipe?
> Win32api.SendMessage can't be used because there is no window for the
> console application. The user keystrokes are captured by my wx-application
> that automates the console application but I don't know how to forward the
> keystroke to Kbhit.
>
> Ciao,
> Frank

You should be able to use PyConsoleScreenBuffer.WriteConsoleInput
to send keystrokes to the app.  The tricky part will be getting a handle
to the console for the child process.

      Roger



More information about the Python-win32 mailing list