I solved the same problem using the above option to get the mouse position on request. Then I started a new thread to do this continuously, doing the rest of the program execution.
MouseInfo.getPointerInfo (). getLocation ()
I also had to make a main class to continue Thread in this way
public class MouseMotion extends Thread {
This requires that you create a function called run. In your void function, just create an infinite loop
public void run() { int n=10; for (int i=0;i<n; n++)
All that remains now is to trigger a stream when you start to watch the movement of the mouse. I start the topic right after my main
public static main (String[] args) throws Exception { Thread thread = new MouseMotion(); thread.start(); ...}
source share