Press enter stops computing python

173 views Asked by At

I'm doing some engineering analysis with the help of a FEA program and Python. When the analysis ends I need to press a key to continue. But this is not a normal press any key to continue. Every code executed with the scripts stops. Like a handput debug break. Nothing runs until I press something or switch windows.

I cant use send keys and subprocesses because running code completely stops. Only solution I could come up with is to use another script in another command window with simple send keys command. This extra script is useless if computer is used or another window is active.

I'm a beginner level programmer and maybe I'm missing something simple. I guess the problem is caused by the FEA programs code but I'm not sure. So is there any way to prevent my code from stopping? Thank you for your time.

1

There are 1 answers

0
ritchie46 On BEST ANSWER

It seems that the FEA program does the windowing and you cannot do much about it. I actually automate scripting in DIANA FEA. For this program I would try something like pywinauto.

https://github.com/pywinauto/pywinauto

And call your python script from another python script.

from pywinauto import Desktop, Application
import time

app = Application().start("FEA_program.exe my_python_script.py")


while True:
    time.sleep(5)

    # send key presses to the app every arbitrary seconds