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


Groups > comp.lang.python > #53990

Re: Send alt key to subprocess.PIPE stdin

X-Received by 10.66.121.226 with SMTP id ln2mr2003300pab.37.1378930548997; Wed, 11 Sep 2013 13:15:48 -0700 (PDT)
X-Received by 10.49.36.8 with SMTP id m8mr2255qej.42.1378930548869; Wed, 11 Sep 2013 13:15:48 -0700 (PDT)
Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!y3no17492557pbx.0!news-out.google.com!rn2ni77589pbc.1!nntp.google.com!b4no12117719pbq.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.python
Date Wed, 11 Sep 2013 13:15:48 -0700 (PDT)
In-Reply-To <mailman.257.1378921806.5461.python-list@python.org>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=65.205.52.2; posting-account=_dIAQQoAAAB7Yieol6fmkK_HviJUbJt3
NNTP-Posting-Host 65.205.52.2
References <38b49476-607e-43ed-bd70-804ff8329ad0@googlegroups.com> <mailman.257.1378921806.5461.python-list@python.org>
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <16f83d11-3bcf-4bf4-9890-cdb896ae1a29@googlegroups.com> (permalink)
Subject Re: Send alt key to subprocess.PIPE stdin
From Wanderer <wanderer@dialup4less.com>
Injection-Date Wed, 11 Sep 2013 20:15:48 +0000
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
Xref csiph.com comp.lang.python:53990

Show key headers only | View raw


On Wednesday, September 11, 2013 1:43:09 PM UTC-4, Gary Herron wrote:
> On 09/11/2013 07:26 AM, Wanderer wrote:
> 
> > How do I send the command 'Alt+D' to subprocess.PIPE?
> 
> >
> 
> > My code is
> 
> >
> 
> > import subprocess
> 
> > rsconfig = subprocess.Popen(["C:\Program Files\Photometrics\PVCam64\utilities\RSConfig\RSConfig.exe", ],stdin=subprocess.PIPE)
> 
> >
> 
> > rsconfig.stdin.write('Alt+D')
> 
> >
> 
> > Thanks
> 
> 
> 
> That question doesn't really make sense.  A pipe provides a method to 
> 
> transfer a stream of bytes.  You could indeed send that byte across the 
> 
> pipe, but it's just a byte, written by one process and read by another 
> 
> process.  The receiving process can examine the byte stream, and do 
> 
> whatever it wants in response.
> 
> 
> 
> By calling it a _command_, you seem to expect some particular behavior 
> 
> out of the receiving process.  Please tell us *what* that might be, and 
> 
> we'll see what we can do to help out.
> 
> 
> 
> Gary Herron
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> Dr. Gary Herron
> 
> Department of Computer Science
> 
> DigiPen Institute of Technology
> 
> (425) 895-4418

I found Sendkeys works.

import subprocess
import time
import SendKeys

rsconfig = subprocess.Popen(["C:\Program Files\Photometrics\PVCam64\utilities\RSConfig\RSConfig.exe", ])
time.sleep(2)
SendKeys.SendKeys('%D\n', with_newlines=True)

Basically there is a dialog with a Done button and 'Alt D' selects the Done button. The subprocess program runs some interface code which sets up an ini file that the rest of the program needs. But then I run into another problem with Windows permissions. The program needs to edit this ini file located in the C:\Windows directory. Windows won't let you without administrator permissions. So then I run into login issues, etc. I kind of gave up and this program has to be run outside my main program. It's annoying since it's just this stupid little text ini file, but I can't convince Windows it doesn't matter if gets edited because it's in a system directory.

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


Thread

Send alt key to subprocess.PIPE stdin Wanderer <wanderer@dialup4less.com> - 2013-09-11 07:26 -0700
  Re: Send alt key to subprocess.PIPE stdin Nobody <nobody@nowhere.com> - 2013-09-11 18:18 +0100
  Re: Send alt key to subprocess.PIPE stdin Gary Herron <gherron@digipen.edu> - 2013-09-11 10:43 -0700
    Re: Send alt key to subprocess.PIPE stdin Wanderer <wanderer@dialup4less.com> - 2013-09-11 13:15 -0700
  Re: Send alt key to subprocess.PIPE stdin Dave Angel <davea@davea.name> - 2013-09-11 20:23 +0000
    Re: Send alt key to subprocess.PIPE stdin Wanderer <wanderer@dialup4less.com> - 2013-09-12 07:06 -0700
      Re: Send alt key to subprocess.PIPE stdin Chris Angelico <rosuav@gmail.com> - 2013-09-13 01:27 +1000
        Re: Send alt key to subprocess.PIPE stdin Nobody <nobody@nowhere.com> - 2013-09-12 18:20 +0100

csiph-web