I need to send an ENTER Keypress to a Background task without GUI. Sound a bit strange, so here is the explanation:
The Executeable is processing medical Data (MRI and CT DICOM Pictures) and creates automated "pre medical reports". They call it AI. This executeable runs on a headless dedicated Windows 2019 Server in a Datacenter (no Linux Binary available - I asked).
They Company who is responsible for this clusterfu** provides Updates (many Updates). They coded a seperate Updater for the "AI".
When I start the Updater it prompts with "New Version found ..." and "Hit Enter to Continue". I dont want to connect and login to the server everytime they provide an update (Login via OpenSSH tunnel and RDP). So I wrote a short Python script who does the job for me. I spare you the details, because actually knowing that a new Update is available involves a HTML Parser and other cruel things.
The script works fine, except for the part with the ENTER Key. Thats because the Server is headles in a DataCenter.
So I cant use something like pywinauto or some autoit Macros to bring the Window to front and hit Enter, because the Updater starts without a Window in the autologin admin account (another story).
My Idea was to open the Updater with subprocess.popen and generate a Pipe to send the Enter Key. But that didnt work. The updater starts, but did not perform any tasks.
proc = subprocess.Popen([r"C:\Program Files\dicomai\ai.exe"], stdin=PIPE)
time.sleep(5)
proc.communicate(b"\n")
I'am out of Ideas and Workarounds.