0

I'm writing on an application that gets signals of the Apple Remote and I'm already finished reading the hardware inputs on the remote. Now i have to replicate these inputs on the remote on something like an keyboard buffer or whatever there exists. I noticed a Java class in java.awt.Robot, but the commands are just send to the Java application itself and not system-wide (!), please correct me if i'm wrong.

But I need a solution to let my program virtually press the keyboard system-wide e.g. to support a pageflip with the arrow keys in a simultaneously launched program like MS Powerpoint.

Any suggestions?

Not working example of my Robot "Robert" (as I'm from Germany) that shall pass the pressed buttons system wide instead of application-wide.

switch(line) {
        case LEFT: System.out.println("left");
                   robert.keyPress(37);
                   robert.keyRelease(37);
                   break;
        case RIGHT: System.out.println("right");
                    robert.keyPress(39);
                    robert.keyRelease(39);
                    break;
        case UP: System.out.println("up");
                    robert.keyPress(38);
                    robert.keyRelease(38);
                    break;
        case DOWN: System.out.println("down");
                    robert.keyPress(38);
                    robert.keyRelease(38);
                    break;
        case PLAYPAUSE: System.out.println("play pause");
                    robert.keyPress(516); // dollar sign
                    robert.keyRelease(516);
                    break;
        case MENU: System.out.println("menu");
                    robert.keyPress(515); // euro sign
                    robert.keyRelease(515);
                    break;
    }
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
AirUp
  • 426
  • 1
  • 8
  • 18
  • https://bitbucket.org/agynamix/ossupport-connector/downloads Fount this useful tool now, seems like there is no suitable solution for system-wide keystroke simulation implemented by java so far :/ – AirUp Aug 14 '12 at 22:14

1 Answers1

0

Actually, the Robot class will be able to control your mouse and keyboard 'system wide', that is you can use it to emulate keyboard input for another application. However, for this application to receive the 'keystrokes', it actually has to have the focus (be 'active').

sarcan
  • 3,145
  • 19
  • 22