Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How can I make MATLAB produce keyboard outputs?

Subject: How can I make MATLAB produce keyboard outputs?

From: Husam Aldahiyat

Date: 27 Dec, 2009 18:27:04

Message: 1 of 4

Hello,
I want MATLAB to "press" certain letters on the keyboard, similar to how it can move the mouse cursor. How can this be done? Perhaps using some secret Java getaround?

Subject: How can I make MATLAB produce keyboard outputs?

From: ds

Date: 27 Dec, 2009 18:38:04

Message: 2 of 4

"Husam Aldahiyat" <numandina@gmail.com> wrote in message <hh88tn$qmb$1@fred.mathworks.com>...
> Hello,
> I want MATLAB to "press" certain letters on the keyboard, similar to how it can move the mouse cursor. How can this be done? Perhaps using some secret Java getaround?

The awt.java.robot is handy for pushing buttons, just be careful.

Subject: How can I make MATLAB produce keyboard outputs?

From: Husam Aldahiyat

Date: 27 Dec, 2009 19:13:03

Message: 3 of 4

"ds " <ds@ds.com> wrote in message <hh89ic$7q8$1@fred.mathworks.com>...
> "Husam Aldahiyat" <numandina@gmail.com> wrote in message <hh88tn$qmb$1@fred.mathworks.com>...
> > Hello,
> > I want MATLAB to "press" certain letters on the keyboard, similar to how it can move the mouse cursor. How can this be done? Perhaps using some secret Java getaround?
>
> The awt.java.robot is handy for pushing buttons, just be careful.

Hey it worked!!!

robot = java.awt.Robot;
lett = 'THANKS';
for k = 1:length(lett)
eval(['robot.keyPress(java.awt.event.KeyEvent.VK_',lett(k),')'])
end

I'm using Java with eval() :)

Subject: How can I make MATLAB produce keyboard outputs?

From: ds

Date: 28 Dec, 2009 15:07:04

Message: 4 of 4

"Husam Aldahiyat" <numandina@gmail.com> wrote in message <hh8bju$gl1$1@fred.mathworks.com>...
> "ds " <ds@ds.com> wrote in message <hh89ic$7q8$1@fred.mathworks.com>...
> > "Husam Aldahiyat" <numandina@gmail.com> wrote in message <hh88tn$qmb$1@fred.mathworks.com>...
> > > Hello,
> > > I want MATLAB to "press" certain letters on the keyboard, similar to how it can move the mouse cursor. How can this be done? Perhaps using some secret Java getaround?
> >
> > The awt.java.robot is handy for pushing buttons, just be careful.
>
> Hey it worked!!!
>
> robot = java.awt.Robot;
> lett = 'THANKS';
> for k = 1:length(lett)
> eval(['robot.keyPress(java.awt.event.KeyEvent.VK_',lett(k),')'])
> end
>
They say that repeated use of eval can cause blindness.
> I'm using Java with eval() :)

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us