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


Groups > comp.lang.python > #17081 > unrolled thread

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

Started byChris Angelico <rosuav@gmail.com>
First post2011-12-13 07:53 +1100
Last post2011-12-13 07:53 +1100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

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

FromChris Angelico <rosuav@gmail.com>
Date2011-12-13 07:53 +1100
SubjectRe: automate commands to an .exe console program through python
Message-ID<mailman.3568.1323723217.27778.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web