automate commands to an .exe console program through python

Chris Angelico rosuav at gmail.com
Tue Dec 13 07:40:50 EST 2011


On Tue, Dec 13, 2011 at 11:35 PM, Juan Perez <corleone82 at gmail.com> wrote:
> My problem is thinking in windows console somewhat like linux shell, and do
> same things I did with pipes in C programming. But it seems not to be the
> case.

It is (at least, it supports the basics of pipes and redirection); but
what you're looking at here is an application that appears not to use
STDIN.

> At a glance I dare say that sendkeys module is useful  enough, but if I've
> understood well, you only can send messages to focused window, that will
> report some inestabilities if windows focused is changed. You won't be able
> to touch anything in the current laptop. So, is there any way to identify
> the a process/window and send keystrokes in a smarter way and/or is it
> possible to identify a window an get the focus on it?

You may be able to put focus to the window before sending it keys, but
this is sounding extremely hackish (nearly as bad as the Magic: The
Gathering Online trade-bot system). I'm thinking here the best option
may be to give this a dedicated virtual machine and let it do whatever
it likes - effectively, have an entire "computer" dedicated to just
this application and its automation harness. That would probably make
things simple enough that you don't need to worry too much about
focus, sending keystrokes to other windows, etc.

ChrisA



More information about the Python-list mailing list