I have two python scripts. First one is just a script waiting for user keyboard input. When user presses a key it prints a pressed key value.
Second script calls first one through 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 got it working when I send through string values. But I don't know how to send keyboard event and how to read it properly.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…