Automatically Entering Inputs into Program

10 次查看(过去 30 天)
Hi,
I am using an old program (Program.exe) that requires you to press ENTER, then enter inputs in the following order: 'A', 'B', 'C'
commandfile = fopen('commandfile.txt','w');
fprintf(commandfile,strcat('\n', 'A', '\n', 'B', '\n', 'C', '\n');
fclose(commandfile);
system('Program.exe < commandfile.txt');
My program then runs into the error LF90.EER error # 94" (this is listed as 'Data transfer beyond end of file').
commandfile = fopen('commandfile.txt','w');
fprintf(commandfile,strcat('\n', 'A', '\n', 'B', '\n', 'C', '\n');
fclose(commandfile);
system('echo commandfile.txt | Program.exe');
My program then runs into the error "ELF90.EER error # 124" (this is listed as 'Unable to read file').
Any insight would be very much appreciated.
  1 个评论
Andrew Klingberg
Andrew Klingberg 2020-11-30
编辑:Andrew Klingberg 2020-11-30
For anyone with a similar issue, I found a work around for now. Instead of sending inputs to the program via a textfile, I can enter them through keystrokes instead.
For my example, here is the code for my purpose:
h = actxserver('WScript.Shell');
h.Run('Program'); %Invokes Program.exe
pause(3); %Waits for Program to load.
h.AppActivate('Program'); %Brings Program to focus
h.SendKeys('~'); %Sends return
pause(5/100); %Waits briefly for program
h.SendKeys('A~'); %Sends A and return
pause(5/100); %Waits briefly for program
h.SendKeys('B~'); %Sends B and return
pause(5/100); %Waits briefly for program
h.SendKeys('C~'); %Sends C and return
pause(5/100); %Waits briefly for program
h.SendKeys('%{F4}'); % closes Program using Alt+F4

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Compiler 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by