Compare commits

..

1 Commits

View File

@@ -14,12 +14,13 @@ public class AutoClicker implements NativeKeyListener {
try {
GlobalScreen.registerNativeHook();
GlobalScreen.addNativeKeyListener(new AutoClicker());
Clicker();
} catch (NativeHookException ex) {
ex.printStackTrace();
}
}
public static void clicker() {
public static void Clicker() {
int mask = InputEvent.BUTTON1_DOWN_MASK;
clickThread = new Thread(() -> {
try {
@@ -29,10 +30,8 @@ public class AutoClicker implements NativeKeyListener {
bot.mouseRelease(mask);
Thread.sleep(10);
}
} catch (AWTException ex) {
} catch (AWTException | InterruptedException ex) {
ex.printStackTrace();
} catch (InterruptedException ex) {
// Thread got close
}
});
clickThread.start();
@@ -42,9 +41,7 @@ public class AutoClicker implements NativeKeyListener {
if(e.getKeyCode() == NativeKeyEvent.VC_F6) {
hotKeyPressed = !hotKeyPressed;
System.out.println("Autoclicker: " + hotKeyPressed);
if(hotKeyPressed) {
clicker();
} else if(clickThread != null) {
if(!hotKeyPressed && clickThread != null) {
clickThread.interrupt();
try {
clickThread.join();