0

I'm trying to open the windows editor (7, 32-bit system) and write to it from a python console (2.7.16, 32-bit). Opening the program works fine via:

p = subprocess.Popen([r'C:\Windows\System32\notepad.exe'], stdin=subprocess.PIPE)

But when I try to make a letter appear in the editor window via

p.communicate(input=b'a')

I get no return value on the command line (prompt not coming back) and nothing happens in the editor. What am I doing wrong?

Robert
  • 432
  • 1
  • 4
  • 15
  • Possible duplicate of [Python - How do I pass a string into subprocess.Popen (using the stdin argument)?](https://stackoverflow.com/questions/163542/python-how-do-i-pass-a-string-into-subprocess-popen-using-the-stdin-argument) – LinPy Sep 04 '19 at 08:38
  • No, this is not a duplicate. I have searched and tried everything (including the stdin.write way). It's just not working. I need a working example of opening the windows editor and writing the letter 'a' to it. – Robert Sep 04 '19 at 08:54
  • I found a clue at https://stackoverflow.com/a/48455097/10375259 Looks like I wrongly assumed sending data to the stdin of a process is the same as the process receiving data from the keyboard. I guess when a process receives data from stdin it can do whatever it wants with that data. In the case of windows editor, it probably just doesn't paste the stdin data to the blank page of the editor! – Robert Sep 04 '19 at 09:42

0 Answers0