Insert an input to an exe automatically by Command Window
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Good morning,
I have to launch a executable file.
I use:
dos('executable.exe')
After that, the exe reports on the Command Window a string which ask me to type an input.
At the moment I should do it time after time.
I tried:
dos('executable.exe < file.txt')
but it doesn't work.
It could be due to the fact that the input file is indicated after the launch of the exe file and not contextually
3 Kommentare
Rik
am 11 Mai 2021
The exe must allow such a thing. Matlab cannot send keystrokes to arbitrary programs.
Akzeptierte Antwort
Jan
am 11 Mai 2021
You could use this to inject keystrokes: https://www.mathworks.com/matlabcentral/fileexchange/40001-keyinject
The function must wait until the corresponding strings appear in the command window, which can be caught by: https://www.mathworks.com/matlabcentral/fileexchange/32005-cmdwintool
But the code must run, during the external program blocks the execution. I assume a timer callback can solve this. But I'd never try this, because this sounds like a programming technique, which is far too complex to be reliable.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Language Fundamentals finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!