gpt4 book ai didi

javascript - Java如何用Robot类来写_

转载 作者:行者123 更新时间:2023-12-01 00:23:50 25 4
gpt4 key购买 nike

我在 Java 代码中使用了机器人类。我想按“_”键,但键码 189 不适用于该代码

public void type() throws Exception

Robot rob = new Robot();

rob.keyPress(189);
rob.keyRelease(189);

最佳答案

正确的方法是使用SHIFT + -

Robot rob = new Robot();
rob.keyPress(KeyEvent.VK_SHIFT);
rob.keyPress(KeyEvent.VK_MINUS);
rob.keyRelease(KeyEvent.VK_MINUS);
rob.keyRelease(KeyEvent.VK_SHIFT);

似乎在法语键盘上以下代码可以工作,因为键盘作为指定的下划线键:

Robot rob = new Robot();
rob.keyPress(KeyEvent.VK_UNDERSCORE);
rob.keyRelease(KeyEvent.VK_UNDERSCORE);

来自this他们说的来源:

Numbers are not prioritized

Writing the numbers on a French keyboard requires using the shift key each time.

That means the AZERTY keyboard prioritizes things like the accented letters (such as é) and brackets - and even the ampersand (&) over numbers.

enter image description here

查看8键,您可以找到下划线。

关于javascript - Java如何用Robot类来写_,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59179186/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com