954,523 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Robot class on a mac computer

Hello,

I got a MacBook Pro for college and i'm trying to program on it. It's all good except when i use the robot class, i don't see any key codes or key events for keys such as function, option, and command. Can i use those keys when using the robot class?

Thanks in advance!

-Nick

caswimmer2011
Light Poster
27 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
 

Robot class to create robotic function of mouse, keyboard and screen... For executing a command or function you can use Runtime class.

http://download.oracle.com/javase/1.4.2/docs/api/java/lang/Runtime.html

Majestics
Practically a Master Poster
621 posts since Jul 2007
Reputation Points: 199
Solved Threads: 49
 

Maybe I did not phrase the question right. I am wondering how to use the robot class with a mac computer because I need to use keys such as function, command, and option. Is there a way to have the computer type those keys for me?

caswimmer2011
Light Poster
27 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
 
Majestics
Practically a Master Poster
621 posts since Jul 2007
Reputation Points: 199
Solved Threads: 49
 

@caswimmer2011 What you want to say ?.

From your posts i understand that you want to use robot class for pressing the function keys (like f1,f2 etc) programatically.
For that you need not worry about your OS or computer type(laptop etc).

IF you want to press function keys for example f1
Here's how you do this..

Robot r=new Robot();
r.keyPress(KeyEvent.VK_F1);


For other keys refer KeyEvent class.

harinath_2007
Posting Whiz
355 posts since Aug 2010
Reputation Points: 78
Solved Threads: 36
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: