Hello all

Im trying to make java robot hold down the command key.

I have used the following code.

robot.keyPress(KeyEvent.VK_META);
robot.Delay(5000);
robot.keyRelease(KeyEvent.VK_META);

This doesant seem to do the trick. Yes I have searched on how to do this but cannot find a working answer.
Am I using the wrong keycode?

Ive also tried

  robot.keyPress(KeyEvent.META_MASK);
 and 

 robot.keyPress(KeyEvent.META_DOWN_MASK);

Ive also tried keycodes, 91 and 93.

Recommended Answers

All 2 Replies

anyone??

Sorry man, the first version looks right to me. Maybe it's OK but there's some other problem that makes it look like its not working?
If you post a runnable test program I can check it out on my Macs.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.