How to control a console based program from Python

Will Stuyvesant hwlgw at hotmail.com
Sat Jan 3 05:24:32 EST 2004


I never used the popen or popen2 libraries but it is my understanding
that they can capture the output of console based programs.  Is it
also possible to send keystrokes to console base programs?

I would like to program a Python program that can play for instance
the tty version of nethack 3.4.3 on Windows, simulating a human
player: for nethack it would not be possible to know if a human or a
computer program is playing it.  It is a console based program, it
accepts keystrokes and outputs characters on the (Windows) console
box.  I did see that WConio can read characters from the screen,
perhaps I can use that, have to experiment with it some more.  But how
to send keystrokes?  Any help and ideas are much appreciated.  And a
happy new year of course!



More information about the Python-list mailing list