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 to run getKeyCode() java function in matlab

Subject: how to run getKeyCode() java function in matlab

From: andandgui isler

Date: 8 Oct, 2010 10:50:04

Message: 1 of 4

i typed ;

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
keyboard=Robot;

    ch=getKeyCode();


i also typed ch=keyboard.getKeyCode();

it didnt work again.. How can i run it properly ?

    

Subject: how to run getKeyCode() java function in matlab

From: Grzegorz Knor

Date: 8 Oct, 2010 11:54:03

Message: 2 of 4

"andandgui isler" <bosisler_ist@hotmail.com> wrote in message <i8mt0s$4qn$1@fred.mathworks.com>...
> i typed ;
>
> import java.awt.AWTException;
> import java.awt.Robot;
> import java.awt.event.KeyEvent;
> keyboard=Robot;
>
> ch=getKeyCode();
>
>
> i also typed ch=keyboard.getKeyCode();
>
> it didnt work again.. How can i run it properly ?
>
>
Robot can't do this.
List of implemented methods:
http://download.oracle.com/javase/1.4.2/docs/api/java/awt/Robot.html

You can press o relase a key, not get.
for example:
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
robot=Robot;
robot.keyPress(KeyEvent.VK_H);
robot.keyRelease(KeyEvent.VK_H);
robot.keyPress(KeyEvent.VK_I);
robot.keyRelease(KeyEvent.VK_I);
robot.keyPress(KeyEvent.VK_SPACE);
robot.keyRelease(KeyEvent.VK_SPACE);
robot.keyPress(KeyEvent.VK_B);
robot.keyRelease(KeyEvent.VK_B);
robot.keyPress(KeyEvent.VK_U);
robot.keyRelease(KeyEvent.VK_U);
robot.keyPress(KeyEvent.VK_D);
robot.keyRelease(KeyEvent.VK_D);
robot.keyPress(KeyEvent.VK_Y);
robot.keyRelease(KeyEvent.VK_Y);
robot.keyPress(KeyEvent.VK_SPACE);
robot.keyRelease(KeyEvent.VK_SPACE);

:)
Grzegorz

Subject: how to run getKeyCode() java function in matlab

From: Steven_Lord

Date: 8 Oct, 2010 14:59:36

Message: 3 of 4



"andandgui isler" <bosisler_ist@hotmail.com> wrote in message
news:i8mt0s$4qn$1@fred.mathworks.com...
> i typed ;
>
> import java.awt.AWTException; import java.awt.Robot; import
> java.awt.event.KeyEvent; keyboard=Robot;

Keep in mind by doing this that you can no longer call the KEYBOARD function
until you clear this variable (or until you exit this function, if it's in a
function.)

http://www.mathworks.com/help/techdoc/ref/keyboard.html

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: how to run getKeyCode() java function in matlab

From: Yair Altman

Date: 9 Oct, 2010 16:34:04

Message: 4 of 4

> Robot can't do this.
> List of implemented methods:
> http://download.oracle.com/javase/1.4.2/docs/api/java/awt/Robot.html


An article describing Java's Robot class and its use in Matlab: http://UndocumentedMatlab.com/blog/gui-automation-robot/

Yair Altman
http://UndocumentedMatlab.com

Tags for 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