Ho creato un oggetto Comando che memorizza la Stringa del comando ed i tasti da premere con la classe robot
e lo costruisco tramite:codice:public Comando(String comando, int tasto1, int tasto2) { this.tasti = new int[2]; this.comando = comando; this.tasti[0] = tasto1; this.tasti[1] = tasto2; }
Quando il client manda il comando esegue il seguente metodocodice:comando[0] = new Comando("Play/Pausa", KeyEvent.CTRL_MASK, KeyEvent.VK_P);
ma mi dà un IllegalArgumentException: Invalid Key Code.. perchè? eppure è lo stesso intero..codice:private void keyPress(int tasti[]) { switch (tasti.length) { case 1://1 tasto robot.keyPress(tasti[0]); robot.delay(35); robot.keyRelease(tasti[0]); break; case 2://2 tasti robot.keyPress(tasti[0]); robot.keyPress(tasti[1]); robot.delay(35); robot.keyRelease(tasti[0]); robot.keyRelease(tasti[1]); break; case 3://3 tasti robot.keyPress(tasti[0]); robot.keyPress(tasti[1]); robot.keyPress(tasti[2]); robot.delay(35); robot.keyRelease(tasti[0]); robot.keyRelease(tasti[1]); robot.keyRelease(tasti[2]); break; } }

Rispondi quotando