Re: Send alt key to subprocess.PIPE stdin
On Wednesday, September 11, 2013 4:23:57 PM UTC-4, Dave Angel wrote: On 11/9/2013 10:26, Wanderer wrote: How do I send the command 'Alt+D' to subprocess.PIPE? That's not a command, it's a keystroke combination. And without knowing what RSConfig.exe is looking to get its keystrokes, it might not even be possible to feed it any keystrokes via the pipe. if the program does indeed use stdin, there's no portable encoding for Alt-D. But if your program only runs on one particular platform, you might be able to find docs for that platform that explain it. My code is import subprocess rsconfig = subprocess.Popen([C:\Program Files\Photometrics\PVCam64\utilities\RSConfig\RSConfig.exe, ],stdin=subprocess.PIPE) That string will only work by accident. You need to make it a raw string, or use forward slashes, or double them. As it happens, with this PARTICULAR set of directories, you won't get into trouble with Python 2.7.3 -- DaveA Thanks, I didn't know that. I thought there would be some \n \t kind of combination or a unicode string for all the key combinations on my keyboard. -- https://mail.python.org/mailman/listinfo/python-list
Re: Send alt key to subprocess.PIPE stdin
On Fri, Sep 13, 2013 at 12:06 AM, Wanderer wande...@dialup4less.com wrote: Thanks, I didn't know that. I thought there would be some \n \t kind of combination or a unicode string for all the key combinations on my keyboard. Unicode identifies every character, but keystrokes aren't characters. Consider, for instance, the difference between the keypress Shift+A and the letter produced - even in the most simple ASCII-only US-only situation, that could produce either A or (if Caps Lock is active) a. So if you actually want to trigger Shift+A, you can't represent that with a character. Controlling a GUI app has to be done with keystrokes, so it needs a GUI controlling tool. That said, though: These sorts of keystrokes often can be represented with escape sequences (I just tried it in xterm and Alt-D came out as \e[d), so you could control a console program using sequences that you could put into a string. But that's not true of your typical GUI system. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Send alt key to subprocess.PIPE stdin
On Fri, 13 Sep 2013 01:27:53 +1000, Chris Angelico wrote: That said, though: These sorts of keystrokes often can be represented with escape sequences (I just tried it in xterm and Alt-D came out as \e[d), Technically, that would be Meta-D (even if your Meta key has Alt printed on it). Alt-char produces chr(ord(char)+128); Meta-char produces \e+char. At least, that's the historical distinction between Meta and Alt. With xterm, the behaviour is configurable via the resources altIsNotMeta, altSendsEscape and metaSendsEscape. None of which has anything to do with trying to feed a GUI program key events via stdin ... -- https://mail.python.org/mailman/listinfo/python-list
Send alt key to subprocess.PIPE stdin
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 -- https://mail.python.org/mailman/listinfo/python-list
Re: Send alt key to subprocess.PIPE stdin
On Wed, 11 Sep 2013 07:26:32 -0700, Wanderer wrote: How do I send the command 'Alt+D' to subprocess.PIPE? You don't. GUI programs don't read stdin, they receive key press events from the windowing system. -- https://mail.python.org/mailman/listinfo/python-list
Re: Send alt key to subprocess.PIPE stdin
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 -- https://mail.python.org/mailman/listinfo/python-list
Re: Send alt key to subprocess.PIPE stdin
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. -- https://mail.python.org/mailman/listinfo/python-list
Re: Send alt key to subprocess.PIPE stdin
On 11/9/2013 10:26, Wanderer wrote: How do I send the command 'Alt+D' to subprocess.PIPE? That's not a command, it's a keystroke combination. And without knowing what RSConfig.exe is looking to get its keystrokes, it might not even be possible to feed it any keystrokes via the pipe. if the program does indeed use stdin, there's no portable encoding for Alt-D. But if your program only runs on one particular platform, you might be able to find docs for that platform that explain it. My code is import subprocess rsconfig = subprocess.Popen([C:\Program Files\Photometrics\PVCam64\utilities\RSConfig\RSConfig.exe, ],stdin=subprocess.PIPE) That string will only work by accident. You need to make it a raw string, or use forward slashes, or double them. As it happens, with this PARTICULAR set of directories, you won't get into trouble with Python 2.7.3 -- DaveA -- https://mail.python.org/mailman/listinfo/python-list