答案 0 :(得分:1)
我用这种方式在我的项目中使用:
Screen screen = new Screen();
screen.click(<your texbox>); // click into textbox to have a cursor there
screen.type("a", KeyModifier.CTRL); // this sends Ctrl+"a" to select all text <- this is what you asked for !
screen.type(Key.BACKSPACE); // this sends Backspace key pressed, i.e. here deletes all selected text
请注意,我同时使用了KeyModifier和Key。这样就有用了。
答案 1 :(得分:1)
试试这个,
Screen screen = new Screen();
screen.type("x",Key.CTRL)
screen.type("\n");
答案 2 :(得分:0)
使用KeyEvent中的密钥代码:
DesktopKeyboard keyboard = new DesktopKeyboard();
keyboard.keyDown(KeyEvent.VK_CONTROL);
keyboard.type("x");
keyboard.keyUp(KeyEvent.VK_CONTROL);