I want to make an app that measures the cursor\'s distance from the center of a component and then moves the cursor back to the center (like most PC video games do). Does an
Hi this will just be adding on. I use a Raspberry PI a lot so I've had to learn how to optimize my code this will be a lot shorter.
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();
}
don't forget to import:
import java.awt.*;