|
|
@@ -31,20 +31,22 @@ public class AntiAfk {
|
|
|
try {
|
|
|
robot = new Robot();
|
|
|
|
|
|
- do {
|
|
|
+ while (true) {
|
|
|
if (windowExists(windowTitle)) {
|
|
|
-
|
|
|
if (timeUntil.calcBetween(timeWhenAfkHappened) >= afkTimerInMs) {
|
|
|
- if (getActiveWindow().equals(getWindowPointer(windowTitle))) {
|
|
|
+ if (getWindowPointer(windowTitle).equals(getActiveWindow())) {
|
|
|
antiAfk(antiAfkKey);
|
|
|
} else {
|
|
|
System.out.println("Need to tab");
|
|
|
Pointer lastWindow = getActiveWindow();
|
|
|
- setActivateWindow(windowTitle);
|
|
|
+ if (!setActivateWindow(windowTitle)) {
|
|
|
+ cantReachClient();
|
|
|
+ continue;
|
|
|
+ }
|
|
|
Thread.sleep(100);
|
|
|
antiAfk(antiAfkKey);
|
|
|
Thread.sleep(300);
|
|
|
- System.out.println(setActivateWindow(lastWindow));
|
|
|
+ setActivateWindow(lastWindow);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -54,12 +56,17 @@ public class AntiAfk {
|
|
|
System.out.println("Not running: " + windowTitle);
|
|
|
}
|
|
|
Thread.sleep(clock);
|
|
|
- } while (true);
|
|
|
+ }
|
|
|
} catch (AWTException | InterruptedException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void cantReachClient() {
|
|
|
+ System.out.println("Can't reach client!");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public boolean windowExists(String windowTitle) {
|
|
|
return User32Util.windowExists(windowTitle);
|
|
|
}
|
|
|
@@ -102,7 +109,7 @@ public class AntiAfk {
|
|
|
if (winProcesstoBeActive == null) return false;
|
|
|
try {
|
|
|
Instant whenSettingStarted = timeUntil.getNowInInstant();
|
|
|
- while (!getActiveWindow().equals(winProcesstoBeActive)) {
|
|
|
+ while (!(winProcesstoBeActive.equals(getActiveWindow()))) {
|
|
|
Thread.sleep(20);
|
|
|
if (timeUntil.calcBetween(whenSettingStarted) >= 8000) return false;
|
|
|
}
|