Fai*_*roz 36
机器人类可以为你做到这一点.以下是移动鼠标光标的示例代码:
try {
// These coordinates are screen coordinates
int xCoord = 500;
int yCoord = 500;
// Move the cursor
Robot robot = new Robot();
robot.mouseMove(xCoord, yCoord);
} catch (AWTException e) {
}
Run Code Online (Sandbox Code Playgroud)
小智 6
嗨,这只是添加。我经常使用 Raspberry PI,所以我必须学习如何优化我的代码,这会短很多。
try {
//moves mouse to the middle of the screen
new Robot().mouseMove((int) Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2, (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2);
//remember to use try-catch block (always, and remember to delete this)
} catch (AWTException e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
不要忘记导入:
import java.awt.*;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
36151 次 |
| 最近记录: |