How to generate output from .exe program via java robot keypress using matlab
Show older comments
hi sir, i want to run an external .exe program from matlab and want to generate output file from that program automatically. The .exe program generates output upon pressing F7 key. so i used java.awt.robot for pressing F7 key.
But the problem is that it doesn't press key when .nec is open it presses key after .exe program is closed. How can i make it able? thanks in advance
function APIrobot()
clear all; close all; clc;
import java.awt.Robot;
import java.awt.event.*;
robot = java.awt.Robot();
robot.delay(2000);
!phi150arm.nec %this is the external .exe program from which i want to generate output
robot.keyPress(KeyEvent.VK_F7);
robot.keyRelease(KeyEvent.VK_F7);
end
3 Comments
dpb
on 6 Jul 2020
Several issues here (and I don't know how to solve any of them otomh, unfortunately...)
Just for starters--
- MATLAB is single-threaded w/o parallel TB so you're correct that system starting the .exe will wait for it unless you use the trailing "&" ampersand to start a new session and go on..that done, the next problem is
- Somehow the keypress has to be directed to the process it's intended for -- how that's done I dunno; one presumes there's something in the package that allows such.
dpb
on 6 Jul 2020
Just saw the following https://www.mathworks.com/matlabcentral/fileexchange/29594-textinject
Don't know if that could be munged/used for purpose or not...
ABDUL MANNAN
on 7 Jul 2020
Edited: ABDUL MANNAN
on 7 Jul 2020
Answers (0)
Categories
Find more on Startup and Shutdown 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!