Sending strings/promts to CMD which open an .exe

2 次查看(过去 30 天)
Tyring to send input to a cmd opened software:
They are just strings but if i ad another dos/system command it just starts a new cmd window. also adding & to each doesent work, i want so send the promts
dos('cd C:\Users\...\folder\ & build.exe')
system('cd C:\Users\...\folder\ & build.exe')
Bold are the strings i want so send but ist doesnt work it just stays till the underlined.
Perple_X version 6.9.1, source updated April 20, 2022.
NO is the default (blank) answer to all Y/N prompts
Enter a name for this project (the name will be used as the
root for all output file names) [default = my_project]:
NAME
The problem definition file will be named: NAME.dat
Enter thermodynamic data file name [default = hp02ver.dat]:
hp03ver.dat
  2 个评论
Alexander Balduin
Alexander Balduin 2022-5-30
编辑:Alexander Balduin 2022-5-30
Not sure how to handle the input, while there is no real documentaion on matlab, and in other Questions no real example...
i startet with this which results like in my first comment above (underlined)
build = System.Diagnostics.Process;
build.StartInfo.FileName = 'C:\Users\...\build.exe'
build.StartInfo.UseShellExecute = true;
build.Start(); % Start the process

请先登录,再进行评论。

采纳的回答

Image Analyst
Image Analyst 2022-5-30
Try something like this:
% Prepare a command string for notepad to open the file.
commandString = sprintf('notepad "%s"', fullFileName);
% Call notepad as a separate process where the user can edit the file.
system(commandString);
  4 个评论
Alexander Balduin
Alexander Balduin 2022-5-30
编辑:Alexander Balduin 2022-5-30
thanks for the long reply! Maybe i should be more precise
i just wanted to create a script which should start a windows cmd which execute a compiled fortran script (its to complex to write it in matlab itself) (here the name is build.exe) where i change only some of the ~25 promts. Because i want to change the parameter like 400x where i read in a matrix in a loop where the values are changed.
The first method doesnt work sadly ....
the java robot doesnt help me too because if i have to do it again because something changed i can´t really reuse it because of the positioning of the mouse, also the its only like write something in the cmd like this:
Is ther an java robor to use keyboard inputs?
name_of_the_file
N
N
2
N
N
CH5C8O
CH3C80
N
1
1 250
200 400
N
11.3 48.1
Y
N
Y
Image Analyst
Image Analyst 2022-5-30
If you are using the window maximized so the widgets are in the same location all the time, then positioning the mouse may work.
There is a keypress option for java robot:
>> methods(mouse)
Methods for class java.awt.Robot:
Robot getClass keyRelease notify wait
createScreenCapture getPixelColor mouseMove notifyAll waitForIdle
delay hashCode mousePress setAutoDelay
equals isAutoWaitForIdle mouseRelease setAutoWaitForIdle
getAutoDelay keyPress mouseWheel toString

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

标签

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by