batch send “ENTER” key to running program

自作多情 提交于 2019-12-12 17:40:58

问题


I have an "old-good" fortran.exe file (without access to the code) and I need to execute a few hundred times using a batch file.

However, at the end of the fortran program, it prints "Press ENTER to exit", interrupting, of course, the execution of the batch file...

Is there a way to send the {ENTER} to the running program?


回答1:


check the sendkeys.bat. The script is capable to send a keys to running program with particular title:

call sendkeys.bat "fortran-program" "{ENTER}"

EDIT

try with this script

call nonsecureSendKeys.bat "progfortr" "{ENTER}"



回答2:


I had the problem recently and this is the easiest/fastest working solution I found:

echo & echo.|fortran.exe

You pipe-in "& echo." (new line) inside the keyboard buffer, waiting to be consumed by the executable.




回答3:


This does not work for the no windowed programs.

Because you should do This : .AppActivate(title).

For the programs run without any window,you can't activate it.



来源:https://stackoverflow.com/questions/36481176/batch-send-enter-key-to-running-program

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!