Compare commits
2 Commits
f1ea71ce52
...
6c6fbb491b
| Author | SHA1 | Date | |
|---|---|---|---|
| 6c6fbb491b | |||
|
|
01ce57cd6e |
@@ -14,13 +14,12 @@ 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 {
|
||||
@@ -30,8 +29,10 @@ public class AutoClicker implements NativeKeyListener {
|
||||
bot.mouseRelease(mask);
|
||||
Thread.sleep(10);
|
||||
}
|
||||
} catch (AWTException | InterruptedException ex) {
|
||||
} catch (AWTException ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (InterruptedException ex) {
|
||||
// Thread got close
|
||||
}
|
||||
});
|
||||
clickThread.start();
|
||||
@@ -41,7 +42,9 @@ public class AutoClicker implements NativeKeyListener {
|
||||
if(e.getKeyCode() == NativeKeyEvent.VC_F6) {
|
||||
hotKeyPressed = !hotKeyPressed;
|
||||
System.out.println("Autoclicker: " + hotKeyPressed);
|
||||
if(!hotKeyPressed && clickThread != null) {
|
||||
if(hotKeyPressed) {
|
||||
clicker();
|
||||
} else if(clickThread != null) {
|
||||
clickThread.interrupt();
|
||||
try {
|
||||
clickThread.join();
|
||||
|
||||
Reference in New Issue
Block a user