Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #17081

Re: automate commands to an .exe console program through python

References <CANShpuLHmCxQFCG+atn-ZjRvGY4CWYXD4F0McTwzq28KB=GGtQ@mail.gmail.com>
Date 2011-12-13 07:53 +1100
Subject Re: automate commands to an .exe console program through python
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.3568.1323723217.27778.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, Dec 13, 2011 at 3:41 AM, Juan Perez <corleone82@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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: automate commands to an .exe console program through python Chris Angelico <rosuav@gmail.com> - 2011-12-13 07:53 +1100

csiph-web