Simulate command window keystrokes from script/m-file

I have an application, that runs through the system's cmd prompt. It takes an input file, along with a series of predictable/fixed keystrokes to process the input, and generate the output. All 'quotes' are supposed to be keystrokes. Manually, this is how it goes:
>open cmd prompt in current folder
>'app input.in'
>'set gust'
>'set oper'
>'x'
>'r'
i now wait 5-10 minutes for the program to finish
>'write output.out'
I'd like to implement the entire process, including typing the fixed keystrokes in matlab, but all answers so far point to using external tools like autohotkey.... I tried using the dos command as follows...
dos(['app input.in']) dos(['set gust']) dos(['set oper']) dos(['x']) dos(['r']) pause(600) dos(['write output.out'])
but that doesn't work, as the program pauses after the first command , and I have no way to enter the keystrokes from my .m file into the command window, without manually typing them in.

回答(1 个)

If the app will read from redirected input, you might be able to use something like this:
'app input.in < keys.txt'
keys.txt is a plain text file with the input you would type, e.g.:
set gust
set oper
x
r
write output.out

1 个评论

Unfortunately, that will not work, as the application doesn't function that way. It's just a FEM software that accepts keystrokes as the only method of user interface.

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 App Building 的更多信息

提问:

Ali
2018-5-24

评论:

Ali
2018-5-27

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by