I am trying to write a python script that will do the following things:
(1) launch a specified .exe file (2) send a series of keystrokes to that file
I've tried using subprocess to open the .exe, and pyautogui to send keystrokes.
import pyautogui as pg
import subprocess
import time
path = 'C: blah blah .exe'
p = subprocess.Popen(path, stdin = subprocess.PIPE_
p.communicate()
pg.write('a bunch of keystrokes')
The issue I am facing is that once subprocess.Popen launches the .exe, the script does not continue unless that .exe program is closed. Is there a way to have the keypresses go through without closing the .exe?
Figured it out. Replaced subprocess.Popen with os.startfile(path).