A brute force solution:
using the software cmdow i meneged to do this in 4 steps: 1. download cmdow from the link: http://www.commandline.co.uk/cmdow/ 2. write a robot matlab code that types like a real person:
function keyboard_robot(varargin)
%types the input as if a user typed it and then press enter
%keyboard_robot(command)
%import
import java.awt.*;
import java.awt.event.*;
rob = Robot;
%extract ascii code from string
mytext = double(varargin{1});
%init the numpad keys
keys = arrayfun(@(d)eval(sprintf('KeyEvent.VK_NUMPAD%d',d)),0:9);
%loop over all characters
for textInd = 1:length(mytext)
%enter the key using ALT + <ascii code>
%hold ALT
rob.keyPress(KeyEvent.VK_ALT);
%loop on digits of each ascii code
for iDig = 3:-1:1
%take the current digit
dig = floor(mod(mytext(textInd), 10^iDig) / 10^(iDig - 1));
%press the digit
rob.keyPress(keys(dig + 1))
pause(0.02)
rob.keyRelease(keys(dig + 1))
end
%release ALT
rob.keyRelease(KeyEvent.VK_ALT);
end
%press Enter
rob.keyPress(KeyEvent.VK_ENTER);
rob.keyRelease(KeyEvent.VK_ENTER);
end
3. compile the function into EXE
4. write a bach file to use the two EXEs:
for /f "tokens=1,9" %%a in ('cmdow /t') do (
if /i "%%b"=="MATLAB" cmdow %%a /ACT
)
keyboard_robot %1
just start the back with parameter of the command: c:\folder> run_matlab_from_cmd.bat my_function(myParameters)
IMPORTENT: i couldn't find a way to move to command window so befor running make shure that the command window is in focus!
enjoy.