I have a executable file (.exe) that performs 3 different actions. Once in its main screen, the user can type '1', '2' or '3', to select which action the .exe must perform.
Now, as many of these actions are performed repeatedly, I am trying to automate this process. That is, I am trying to create a script that, based on a specific rule, determines which action is needed and, then, execute the .exe file, and type and send either '1', '2' or '3' (plus ENTER) in the executable screen.
I have tried this using:
BAT
: Calling the .exe file withSTART
, but I dont think it is possible to interact with the program after it is launched. It would be possible to send the options as a parameter, but the .exe file doesnt accept any.AutoHotKey
: I have never used it before, and I couldnt find in the documentation a way to type and send commands to the program.Python
: I tried usingpopen
, and I could execute the .exe file, but then again, could not send the '1', '2' or '3' options. The code used for that is:
.
import time
from subprocess import Popen, PIPE
process = Popen(["executable.exe", "1"], stderr=PIPE, shell=True)
stdout, stderr = process.communicate()
time.sleep(2)
process.communicate("1") # send '1' to select action
This launches the .exe file, but doesn type and send '1' in the program screen to select the action.