Код: Выделить всё
import com.sun.jdi.request.MethodExitRequest;
import java.awt.*;
import java.awt.event.*;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws AWTException {
int Cooldown = 200;
int Bullets = 10000;
Scanner sc = new Scanner(System.in);
System.out.println("type 1 OR 2 to start");
int x = sc.nextInt();
if (x == 1) {
for (int i = 0; i < Bullets; i++) {
mouseclick2();
wait(Cooldown);
mouseclick3();
wait(Cooldown);
}
} else if (x == 2) {
for (int i = 0; i < Bullets; i++) {
mouseclick2();
wait(Cooldown);
mouseclick3();
wait(Cooldown);
mouseclick4();
wait(Cooldown);
}
}
}
public static void wait(int x) {
try {
Thread.sleep(x);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
public static void mouseclick2() throws AWTException {
Robot bot = new Robot();
bot.keyPress(KeyEvent.VK_2);
bot.keyRelease(KeyEvent.VK_2);
}
public static void mouseclick3() throws AWTException {
Robot bot = new Robot();
bot.keyPress(KeyEvent.VK_3);
bot.keyRelease(KeyEvent.VK_3);
}
public static void mouseclick4() throws AWTException {
Robot bot = new Robot();
bot.keyPress(KeyEvent.VK_4);
bot.keyRelease(KeyEvent.VK_4);
}
}
Подробнее здесь: https://stackoverflow.com/questions/786 ... a-key-java