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 件)
Jeff Miller
2018 年 5 月 25 日
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
カテゴリ
ヘルプ センター および File Exchange で App Building についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!