I am writing a dictionary program with requires switching keyboard layout.
I have kde set up that ctrl-alt-k switches layout.
I have tried simulating the ctrl-alt-k keypress from the program but this doesn't seem to do anything.
try {
Robot r = new Robot();
r.keyPress(KeyEvent.VK_CONTROL);
r.keyPress(KeyEvent.VK_ALT);
r.keyPress(KeyEvent.VK_K);
r.keyRelease(KeyEvent.VK_K);
r.keyRelease(KeyEvent.VK_CONTROL);
r.keyRelease(KeyEvent.VK_ALT);
} catch (Exception e) {
e.printStackTrace();
}
Why doesn't this work? I have managed to simulate ctrl-c with similar code but this does nothing.