Java Robot mouse move: setting speed?

时光怂恿深爱的人放手 提交于 2019-12-04 12:30:29

The Robot class has a delay(...) method that you can use to control movement from point to point. Try a few different alogorithms to determine what you like.

Geoff

Here is a pretty good way here:

Consider start_x where your mouse starts and end_x where you are wanting it to end. Same for y

for (int i=0; i<100; i++){  
    int mov_x = ((end_x * i)/100) + (start_x*(100-i)/100);
    int mov_y = ((end_y * i)/100) + (start_y*(100-i)/100);
    robot.mouseMove(mov_x,mov_y);
    robot.delay(10);
}

Hope that helps...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!