Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.ag!news2.euro.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python,': 0.01; 'automate': 0.05; 'parameter': 0.05; 'python': 0.08; 'keystrokes': 0.09; 'subject:python': 0.10; 'programmer': 0.10; 'am,': 0.12; 'gui': 0.13; 'received:209.85.210.174': 0.13; 'received:mail- iy0-f174.google.com': 0.13; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'how,': 0.16; 'ideally,': 0.16; 'stdin': 0.16; 'stdin,': 0.16; 'wrote:': 0.18; 'dec': 0.22; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; 'mode': 0.25; 'code': 0.25; "i'm": 0.26; 'tried': 0.27; 'script': 0.28; 'message-id:@mail.gmail.com': 0.28; 'script.': 0.29; 'subject: .': 0.29; 'cmd': 0.30; 'juan': 0.30; 'remains': 0.30; 'usually': 0.31; "i've": 0.31; 'actual': 0.32; 'tue,': 0.32; "can't": 0.32; 'to:addr:python-list': 0.34; 'probably': 0.34; 'done.': 0.34; 'anything': 0.34; 'automation': 0.34; 'running': 0.35; '...': 0.36; 'but': 0.37; 'received:google.com': 0.37; 'problems': 0.37; 'open': 0.38; 'using': 0.38; 'received:209.85': 0.38; 'characters': 0.39; 'goes': 0.39; "it's": 0.40; 'received:209': 0.40; 'to:addr:python.org': 0.40; 'one,': 0.40; 'more': 0.61; '2011': 0.61; 'worth': 0.61; 'your': 0.61; 'accepts': 0.64; 'opened': 0.64; 'subject:program': 0.67; 'hey,': 0.78; 'comunicate': 0.84; 'subject:.exe': 0.84; 'subject:commands': 0.84; 'window,': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=dkEdmwVQSPWy7Q+8/RVUyOWWP6vfWaLDfozpiuyfFhk=; b=oAMW6lRfKvstb3AICn4tWo49UeSmql5YTrilHKeXKSbFhk0ql2Va4gbvClnMTjDg5f 6t0ahc3jR3zrfetv4kCgT2joTIcPbUZUZjn0DQyHaGI7J80ql7QUDpB6MsjpG1jRDEeI ZZvpQ4W+k/bKZGVlWyKdb7n6ROZcBsaz3gBUI= MIME-Version: 1.0 In-Reply-To: References: Date: Tue, 13 Dec 2011 07:53:35 +1100 Subject: Re: automate commands to an .exe console program through python From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1323723217 news.xs4all.nl 6984 [2001:888:2000:d::a6]:50976 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:17081 On Tue, Dec 13, 2011 at 3:41 AM, Juan Perez 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 hav= ing > 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=A0 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