Automatically Entering Inputs into Program

8 views (last 30 days)
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 Comment
Andrew Klingberg
Andrew Klingberg on 30 Nov 2020
Edited: Andrew Klingberg on 30 Nov 2020
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

Sign in to comment.

Answers (0)

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!