Compare commits
No commits in common. "inactivity-monitor" and "main" have entirely different histories.
inactivity
...
main
@ -4,12 +4,9 @@ import com.github.kwhat.jnativehook.GlobalScreen;
|
|||||||
import com.github.kwhat.jnativehook.NativeHookException;
|
import com.github.kwhat.jnativehook.NativeHookException;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import wtf.beatrice.autosqueal.listener.CursorMoveListener;
|
|
||||||
import wtf.beatrice.autosqueal.listener.KeyPressListener;
|
import wtf.beatrice.autosqueal.listener.KeyPressListener;
|
||||||
import wtf.beatrice.autosqueal.ui.MainWindow;
|
import wtf.beatrice.autosqueal.ui.MainWindow;
|
||||||
|
|
||||||
import java.util.Timer;
|
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger(Main.class);
|
private static final Logger LOGGER = LogManager.getLogger(Main.class);
|
||||||
@ -20,10 +17,6 @@ public class Main {
|
|||||||
|
|
||||||
registerJNativeHook();
|
registerJNativeHook();
|
||||||
mainWindow.init();
|
mainWindow.init();
|
||||||
|
|
||||||
Timer timerRunner = new Timer();
|
|
||||||
CursorMoveListener cursorMoveListener = new CursorMoveListener();
|
|
||||||
timerRunner.schedule(cursorMoveListener, 0L, 1000L);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerJNativeHook() {
|
private static void registerJNativeHook() {
|
||||||
|
@ -15,7 +15,6 @@ public class CursorMover extends TimerTask
|
|||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger(CursorMover.class);
|
private static final Logger LOGGER = LogManager.getLogger(CursorMover.class);
|
||||||
private final Random random;
|
private final Random random;
|
||||||
private SingleStepMovementTask singleStepMovementTask;
|
|
||||||
|
|
||||||
private static final int LOOPS_BEFORE_CLICK = 5;
|
private static final int LOOPS_BEFORE_CLICK = 5;
|
||||||
|
|
||||||
@ -23,7 +22,6 @@ public class CursorMover extends TimerTask
|
|||||||
|
|
||||||
public CursorMover() {
|
public CursorMover() {
|
||||||
random = new SecureRandom();
|
random = new SecureRandom();
|
||||||
singleStepMovementTask = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -37,6 +35,8 @@ public class CursorMover extends TimerTask
|
|||||||
int destX;
|
int destX;
|
||||||
int destY;
|
int destY;
|
||||||
|
|
||||||
|
SingleStepMovementTask singleStepMovementTask;
|
||||||
|
|
||||||
if (iteration == LOOPS_BEFORE_CLICK) {
|
if (iteration == LOOPS_BEFORE_CLICK) {
|
||||||
destX = RunnerUtil.SCREEN_WIDTH - 5;
|
destX = RunnerUtil.SCREEN_WIDTH - 5;
|
||||||
destY = 5;
|
destY = 5;
|
||||||
@ -67,11 +67,6 @@ public class CursorMover extends TimerTask
|
|||||||
|
|
||||||
Timer timer = new Timer();
|
Timer timer = new Timer();
|
||||||
timer.schedule(singleStepMovementTask, 0L, 2L);
|
timer.schedule(singleStepMovementTask, 0L, 2L);
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isRunning() {
|
|
||||||
if (singleStepMovementTask == null) return false;
|
|
||||||
|
|
||||||
return singleStepMovementTask.isRunning();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ public class SingleStepMovementTask extends TimerTask {
|
|||||||
|
|
||||||
float stepX = 1;
|
float stepX = 1;
|
||||||
float stepY = 1;
|
float stepY = 1;
|
||||||
private boolean isRunning = true;
|
boolean isRunning = true;
|
||||||
boolean click;
|
boolean click;
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@ package wtf.beatrice.autosqueal.listener;
|
|||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import wtf.beatrice.autosqueal.Main;
|
|
||||||
import wtf.beatrice.autosqueal.util.RunnerUtil;
|
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
@ -27,8 +25,6 @@ public class CursorMoveListener extends TimerTask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if(RunnerUtil.isSquealing()) return;
|
|
||||||
|
|
||||||
int newX = MouseInfo.getPointerInfo().getLocation().x;
|
int newX = MouseInfo.getPointerInfo().getLocation().x;
|
||||||
int newY = MouseInfo.getPointerInfo().getLocation().y;
|
int newY = MouseInfo.getPointerInfo().getLocation().y;
|
||||||
|
|
||||||
@ -37,15 +33,14 @@ public class CursorMoveListener extends TimerTask {
|
|||||||
loops = 0;
|
loops = 0;
|
||||||
LOGGER.info("User is no longer away!");
|
LOGGER.info("User is no longer away!");
|
||||||
} else {
|
} else {
|
||||||
if (loops < 10) {
|
if (loops < 30) {
|
||||||
loops++;
|
loops++;
|
||||||
} else {
|
} else {
|
||||||
LOGGER.info("User is away!");
|
LOGGER.info("User is away!");
|
||||||
Main.getMainWindow().toggleRunning();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isUserAway = loops >= 10;
|
isUserAway = loops >= 30;
|
||||||
|
|
||||||
oldX = newX;
|
oldX = newX;
|
||||||
oldY = newY;
|
oldY = newY;
|
||||||
|
@ -50,6 +50,7 @@ public class MainWindow
|
|||||||
timestampLabel.setBounds(new Rectangle(bordersPx, bordersPx + rescaleHeight + bordersPx, 100, 30));
|
timestampLabel.setBounds(new Rectangle(bordersPx, bordersPx + rescaleHeight + bordersPx, 100, 30));
|
||||||
frame.add(timestampLabel);
|
frame.add(timestampLabel);
|
||||||
|
|
||||||
|
|
||||||
frame.setLayout(null);
|
frame.setLayout(null);
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
}
|
}
|
||||||
@ -105,6 +106,8 @@ public class MainWindow
|
|||||||
|
|
||||||
if (cursorMover == null) {
|
if (cursorMover == null) {
|
||||||
timerRunner = new Timer();
|
timerRunner = new Timer();
|
||||||
|
CursorMoveListener cursorMoveListener = new CursorMoveListener();
|
||||||
|
timerRunner.schedule(cursorMoveListener, 0L, 1000L);
|
||||||
|
|
||||||
cursorMover = new CursorMover();
|
cursorMover = new CursorMover();
|
||||||
timerRunner.schedule(cursorMover, 1000L, RunnerUtil.SECONDS_BETWEEN_MOVES * 1000L);
|
timerRunner.schedule(cursorMover, 1000L, RunnerUtil.SECONDS_BETWEEN_MOVES * 1000L);
|
||||||
@ -131,12 +134,4 @@ public class MainWindow
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public boolean isRunning() {
|
|
||||||
if (cursorMover == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return cursorMover.isRunning();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package wtf.beatrice.autosqueal.util;
|
package wtf.beatrice.autosqueal.util;
|
||||||
|
|
||||||
import wtf.beatrice.autosqueal.Main;
|
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public class RunnerUtil {
|
public class RunnerUtil {
|
||||||
@ -15,8 +13,4 @@ public class RunnerUtil {
|
|||||||
public static final int SCREEN_HEIGHT = Toolkit.getDefaultToolkit().getScreenSize().height;
|
public static final int SCREEN_HEIGHT = Toolkit.getDefaultToolkit().getScreenSize().height;
|
||||||
public static final int SCREEN_WIDTH = Toolkit.getDefaultToolkit().getScreenSize().width;
|
public static final int SCREEN_WIDTH = Toolkit.getDefaultToolkit().getScreenSize().width;
|
||||||
|
|
||||||
public static boolean isSquealing() {
|
|
||||||
return Main.getMainWindow().isRunning();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user