automate commands to an .exe console program through python
Tim Golden
mail at timgolden.me.uk
Tue Dec 13 06:34:31 EST 2011
On 13/12/2011 11:21, Juan Perez wrote:
> Well, if developers have to change something to the code, I'd continue
> with autoit, since is closer to real enviroment. You are right, autoit
> work by send parametres to GUI focused, but really I don't think it's
> something necessary for my purposes as I need only send parameters to a
> windows cmd console. Do you know if is that possible by piping standard
> input? I've tried but with no results. What I'd need is open a new
> windows console get the pid and send messages to it through stdin pipe.
> But I've been unable to do it so far.
I think that you're thinking about this the wrong way. You're talking
about automating a Console program as though it were notepad: by sending
keystrokes. Mixed in with that you've got some kind of notion of piping
stdin/stdout.
If you've got a (non-GUI) program which you usually run in a Console
context, it will either take its input from stdin -- in which case,
ignore the fact it runs in a console and feed it via subprocess --
or it will take input from some kind of Console-level getch method,
in which case you'll have to use something like SendKeys [1] or perhaps
WinPexpect [2]
Don't know if that helps at all...
TJG
[1] http://www.rutherfurd.net/python/sendkeys/
[2] https://bitbucket.org/geertj/winpexpect/wiki/Home
More information about the Python-list
mailing list