What's wrong on using Popen's communicate method?
On Thu, 04 Jul 2019 10:36:36 +1000, Cameron Simpson wrote:
> On 03Jul2019 16:57, Jach Fong <jfong at ms4.hinet.net> wrote:
>>I have the test0.py below. I expect to see 'abcd' showing in the notepad window:
>>import subprocess as sp
>>p0 = sp.Popen('notepad.exe', stdin=sp.PIPE)
>>But nothing happens. The notepad is completely empty. What have I missed?
>>PS. I am using python 3.4 on Windows Vista
> Well I am not a Windows person, but in most GUI environments a desktop
> app such as Notepad does not read from its standard input - it reads
> keyboard stuff though the GUI interface instead. So it is ignoring your
> input data - this approach will generally fail with any desktop app on
> any platform.
> You may need to investigate generating synthetic keystrokes somehow.
> Or alternatively write your data to a text file and hand the name of the
> text file to notepad as a file to edit.
> Cameron Simpson <cs at cskk.id.au>
I block googlegroups so I don't see the original post. I am
talking to the OP.
Take a look at the SendKeys module.
<Wildman> GNU/Linux user #557453
The cow died so I don't need your bull!