I have two python scripts. The first is just a script waiting for user keyboard input. When the user presses a key, he prints the pressed key value.
The second script calls first one through a subprocess using Popen, like this
p = Popen('python first_script.py', shell=True, universal_newlines=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT)
print p.communicate(input="some value paased through")[0]
I worked when sending string values. But I do not know how to send a keyboard event and how to read it correctly.
source
share