Java Robot mouse engine: installation speed?

The Java Robot class allows you to move the mouse as if the actual physical mouse was moved.

However, how to move the mouse from Point1 to Point2 in a humane (and therefore not instantaneous) order? Aka, how to set the speed of movement?

If this speed is not possible in the Robot class, so if the mouse can only be moved instantly, what β€œalgorithm” should be used to simulate mouse movement? Should it move the mouse pixel to pixel at a certain zoom rate?

+3
source share
2 answers

Robot (...), . , , .

0

:

start_x, , end_x, , . 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);
}

, ...

+4

All Articles