Basically, I'm trying to build a rapid fire script for some game I'm playing, but I have no idea how to make it start upon holding the left mouse button down, and stop upon releasing it, help would be nice.
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class RapidFire {
public static int rate = 0;
public static void main(String[] args) {
while (rate == 0) {
try {
System.out.println("Speed of the auto-clicker (in miliseconds):");
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
try {
rate = Integer.parseInt(in.readLine());
if (rate < 100) {
rate = 0;
System.out.println("Must be at least 100 miliseconds.");
}
} catch (NumberFormatException ex) {
System.out.println("Error - please try again.");
}
} catch (IOException e) {}
}
try {
Robot robot = new Robot();
while (true) {
try {
Thread.sleep(rate);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
} catch (InterruptedException ex) {}
}
} catch (AWTException e) {}
}
}
Basically, I'm trying to build a rapid fire script for some game I'm playing, but I have no idea how to make it start upon holding the left mouse button down, and stop upon releasing it, help would be nice.
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class RapidFire {
public static int rate = 0;
public static void main(String[] args) {
while (rate == 0) {
try {
System.out.println("Speed of the auto-clicker (in miliseconds):");
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
try {
rate = Integer.parseInt(in.readLine());
if (rate < 100) {
rate = 0;
System.out.println("Must be at least 100 miliseconds.");
}
} catch (NumberFormatException ex) {
System.out.println("Error - please try again.");
}
} catch (IOException e) {}
}
try {
Robot robot = new Robot();
while (true) {
try {
Thread.sleep(rate);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
} catch (InterruptedException ex) {}
}
} catch (AWTException e) {}
}
}
tfw hacking with java
As for the program, where is "while (true)" boolean declared, initialized, or read from?
And what is Robot?