Robot drag class

I would like to drag using the Robot class in Java. For some reason, the code below does not work. Is there an alternative to this method?

public static void main (String args []){ Robot robot = new Robot (); robot.mouseMove(350, 226); robot.keyPress(InputEvent.BUTTON1_MASK); robot.mouseMove(250, 350); robot.keyRelease(InputEvent.BUTTON1_MASK); 

}

+4
source share
1 answer

You need to use mousePress() and mouseRelease() , not keyPress() and keyRelease()

+2
source

Source: https://habr.com/ru/post/1397471/


All Articles