I wrote code that changes the layout language on the PC until English is selected, the language changes, the key combination is correct, but the loop continues forever
InputContext context = InputContext.getInstance();
Locale curLocale = context.getLocale();
while(!curLocale.equals(Locale.US)) {
robot.keyPress(KeyEvent.VK_SHIFT);
robot.keyPress(KeyEvent.VK_ALT);
robot.keyRelease(KeyEvent.VK_SHIFT);
robot.keyRelease(KeyEvent.VK_ALT);
Thread.sleep(500);
context = InputContext.getInstance();
curLocale = context.getLocale();
}
That is, the old layout value is written to curLocale