I am trying to automate some tasks using Python. The task involves running some .exe code, and the .exe code, at the end needs user to press a key to finish. Here is my problem:
In my code I need to run the .exe two times, so my code looks like this:
p = subprocess.Popen('MyCode.exe')
PressKey(13)
p.wait()
...
p = subprocess.Popen('MyCode.exe')
PressKey(13)
p.wait()
And the PressKey()
function is copied from HERE.
My problem is that it looks like the first PressKey(13)
function call works and causes the .exe subproces to finish and python will move on to the next line, but then the second time the subprocess is executed the PressKey(13)
does not have any effect and the .exe code stays at the stage that asks user to press a key. I even tried adding a PressKey(13)
after the p.wait()
as well and it didn't help.
Any help on this is really appreciated.