I have wrote a simple auto-clicking script and it works fine, as in it clicks every time i believe it should. One thing i am wondering about it though, It is meant to be delayed on a random interval between 2500 milliseconds and 5000 milliseconds. I am just not 100% it is doing that?
All of the code is here:
public static void click(int desiredAmount)
{
int counter = 0;
Random rand = new Random();
while (counter < desiredAmount)
{
try {
Thread.sleep(rand.nextInt(5000-2500) + 2500);
} catch (InterruptedException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
robot.mousePress(MouseEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK);
++counter;
}
}
just a simple method that does the clicking, my concern is raised on this line of code Thread.sleep(rand.nextInt(5000-2500) + 2500);
I am using the nextInt(int x)
method to get a random INT between two values, but the Thread.sleep();
method I'm using takes a long
as a param. Does this mean it will truncate or something? instead of it being 2500 milliseconds it will just be 2 seconds? or 3 seconds or 4 seconds instead of 2646 milliseconds or 3876 milliseconds etc?
Is it actually delaying each click by a random millisecond from 2500-5000? I'm having a hard time figuring that out.