automate commands to an .exe console program through python

Juan Perez corleone82 at gmail.com
Tue Dec 13 06:21:07 EST 2011


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.

Thanks,

Juan

2011/12/12 Chris Angelico <rosuav at gmail.com>

> On Tue, Dec 13, 2011 at 3:41 AM, Juan Perez <corleone82 at gmail.com> wrote:
> > I need to automate a .exe console program in windows, and send key
> > characters like 'a', 'M' ...
> > I had this running in an autoIT script which with only activating cmd
> > window, and with the "send" parameter I had all already done. But I'm
> having
> > a lot of problems with python, I've tried with process.call,
> communicate(),
> > os.popen ... but no results. I can't comunicate with the program and
> even i
> > can't maintain it opened more than  a few seconds. If I open a program
> like
> > notepad.exe it remains opened but when I try to comunicate with the stdin
> > pipe just don't write anything to the program.
>
> GUI programs such as Notepad usually don't read from STDIN, which is
> where text goes if you write to a pipe. You may have to check out how,
> exactly, the program accepts commands; your autoIT script is probably
> sending keystrokes using the Wndows GUI, so it works as long as the
> program has focus.
>
> Ideally, look into whether the program has an actual automation mode -
> and if it doesn't have one, ask the programmer to expose his code
> directly to a Python script. Hey, it's worth a shot! :)
>
> ChrisA
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20111213/d8421c53/attachment.html>


More information about the Python-list mailing list