Saturday, May 31, 2025

[JAVA] AUTO CLICK REPEAT DELAY

import java.awt.*;
import java.awt.event.InputEvent;
import java.util.Timer;
import java.util.TimerTask;

public class AutoClicker {

    public static void main(String[] args) throws AWTException {
        Robot robot = new Robot();
        int delay = 100; // milliseconds between clicks

        Timer timer = new Timer();
        timer.scheduleAtFixedRate(new TimerTask() {
            @Override
            public void run() {
                robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); // Left click down
                robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); // Left click up
            }
        }, 0, delay);
    }
}

No comments: