Fixed bug of the autoclicker not being able to click (ironic I know) #2
@@ -14,13 +14,12 @@ public class AutoClicker implements NativeKeyListener {
|
|||||||
try {
|
try {
|
||||||
GlobalScreen.registerNativeHook();
|
GlobalScreen.registerNativeHook();
|
||||||
GlobalScreen.addNativeKeyListener(new AutoClicker());
|
GlobalScreen.addNativeKeyListener(new AutoClicker());
|
||||||
Clicker();
|
|
||||||
} catch (NativeHookException ex) {
|
} catch (NativeHookException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Clicker() {
|
public static void clicker() {
|
||||||
int mask = InputEvent.BUTTON1_DOWN_MASK;
|
int mask = InputEvent.BUTTON1_DOWN_MASK;
|
||||||
clickThread = new Thread(() -> {
|
clickThread = new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
@@ -30,8 +29,10 @@ public class AutoClicker implements NativeKeyListener {
|
|||||||
bot.mouseRelease(mask);
|
bot.mouseRelease(mask);
|
||||||
Thread.sleep(10);
|
Thread.sleep(10);
|
||||||
}
|
}
|
||||||
} catch (AWTException | InterruptedException ex) {
|
} catch (AWTException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
// Thread got close
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
clickThread.start();
|
clickThread.start();
|
||||||
@@ -41,7 +42,9 @@ public class AutoClicker implements NativeKeyListener {
|
|||||||
if(e.getKeyCode() == NativeKeyEvent.VC_F6) {
|
if(e.getKeyCode() == NativeKeyEvent.VC_F6) {
|
||||||
hotKeyPressed = !hotKeyPressed;
|
hotKeyPressed = !hotKeyPressed;
|
||||||
System.out.println("Autoclicker: " + hotKeyPressed);
|
System.out.println("Autoclicker: " + hotKeyPressed);
|
||||||
if(!hotKeyPressed && clickThread != null) {
|
if(hotKeyPressed) {
|
||||||
|
clicker();
|
||||||
|
} else if(clickThread != null) {
|
||||||
clickThread.interrupt();
|
clickThread.interrupt();
|
||||||
try {
|
try {
|
||||||
clickThread.join();
|
clickThread.join();
|
||||||
|
|||||||
Reference in New Issue
Block a user