Question: Java auto Clicker Right now I have the code for auto clicker it just make a click in one place is there anyway i can
Java auto Clicker
Right now I have the code for auto clicker it just make a click in one place is there anyway i can set up the click automatically in different location? for example
First Location User set it up on the top (For example Chegg Study Logo is)
Second Location user set it up on the bottom (Where Microsoft windows logo is)
and can they click it on sequence. so first it press to the top then second they press the bottom windows.
My code right now is only clicking where the mouse is. is there anyway to make robot move like this this?
this is my code:
import java.awt.AWTException; import java.awt.Robot;
public class AutoClicker { private Robot robot; private int delay; public AutoClicker() { try { robot = new Robot(); } catch (AWTException e) { // TODO Auto-generated catch block e.printStackTrace(); } delay = 300; } public void clickMouse (int button) { try { robot.mousePress(button); robot.delay(delay); robot.mouseRelease(button); robot.delay(delay); } catch(Exception e) { e.printStackTrace(); } } public void setDelay(int ms) { this.delay = ms; } }
this is my main code
import java.awt.event.InputEvent; import java.lang.Thread; import java.util.Scanner;
public class main {
public static void main(String[] args) { // TODO Auto-generated method stub Scanner scanner = new Scanner(System.in); System.out.println("AutoClick"); System.out.print("Desire Click" ); int click = scanner.nextInt(); System.out.print("Enter delay "); int delay = scanner.nextInt(); System.out.println("Program will start in 3 sec "); try { Thread.sleep(3000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } AutoClicker clicker = new AutoClicker(); clicker.setDelay(delay); for (int i = 0; i < click; i ++) { clicker.clickMouse(InputEvent.BUTTON1_MASK); } System.out.println("Finish");
}
}
and they will press it in order until the user stop the program.
I know we should use robot.mouseMove( x , y); but i am not sure how to set these up. This is not homework or assignment this is only to gain knowlege of Java since i am still very bad, and i need practice
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
