Compare commits

...

34 Commits

Author SHA1 Message Date
35c705222b implement initial support for inactivity monitor
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-06 16:19:04 +02:00
8ab50d7e81 remove ocr leftovers
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-06 10:27:20 +02:00
399db2b27c fix typo
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-06 10:24:27 +02:00
7ca9431fea start correct versioning scheme
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-06 10:22:28 +02:00
86bc795fe4 update readme
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-06 10:19:09 +02:00
41d414fb7e update readme
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-06 10:16:01 +02:00
8b048d71ed update readme
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-06 10:15:32 +02:00
059b445e01 update readme
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-06 10:14:06 +02:00
bc14aa40fe update readme
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-06 10:08:15 +02:00
5b63e9cb29 update readme
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-06 10:00:00 +02:00
19ca8a713b update readme
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-06 09:59:31 +02:00
c97a3038f2 change multiple small things
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-06 00:35:46 +02:00
8ef9ea9288 Add timestamp screenshot for MacOS on debugging UI
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-05 23:52:13 +02:00
bef4913447 update readme.md
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-05 23:16:58 +02:00
4d2d3403d6 Fix build error
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-05 21:41:39 +02:00
7cc01d9d29 Fix build error
Some checks failed
continuous-integration/drone/push Build is failing
2024-08-05 21:38:53 +02:00
c3c1b99f1b Improve code quality
Some checks failed
continuous-integration/drone/push Build is failing
2024-08-05 21:36:44 +02:00
9ad074bb51 Optimize imports
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-05 21:30:08 +02:00
a6c43fd646 Improve button and keystrokes handling
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-05 21:29:02 +02:00
ab1a0a753c Re-interrupt method
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-05 20:57:14 +02:00
3e4c490183 Update gitignore
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-05 20:50:26 +02:00
48f12a1640 Fix clicking on clock every X times 2024-08-05 20:50:03 +02:00
b038098c3c Refactor packages and add GUI with start button
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-05 20:39:14 +02:00
9c0b3290f7 Use SecureRandom
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-05 19:28:35 +02:00
d55817f463 Use logger instead of raw logging
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-05 19:25:21 +02:00
7567552c1a Do not use infinite loop
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-05 19:24:00 +02:00
15bf2f80a1 Add readme
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-05 19:21:51 +02:00
46265e99b1 Improve linting
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-05 19:18:44 +02:00
d841288db7 Update .drone.yml
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-05 19:11:19 +02:00
593603aec2 Update .drone.yml
Some checks failed
continuous-integration/drone/push Build is failing
2024-08-05 19:10:42 +02:00
e3c708e49d Remove SonarQube from DroneCI
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-05 19:07:23 +02:00
06eac10bbf Fix config
Some checks failed
continuous-integration/drone/push Build is failing
2024-08-05 19:06:39 +02:00
2e67f9b150 Update DroneCI integration with SonarQube
Some checks failed
continuous-integration/drone/push Build encountered an error
2024-08-05 19:05:49 +02:00
64bc9a4313 Add DroneCI support
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-05 18:54:51 +02:00
12 changed files with 426 additions and 87 deletions

31
.drone.yml Normal file
View File

@@ -0,0 +1,31 @@
kind: pipeline
name: default
platform:
os: linux
arch: arm64
steps:
# test if it compiles correctly
- name: build
image: maven:3-eclipse-temurin-17
commands:
- mvn verify --no-transfer-progress -DskipTests=true -Dmaven.javadoc.skip=true -B -V
# run unit tests
- name: test
image: maven:3-eclipse-temurin-17
commands:
- mvn test --no-transfer-progress -B -V
# run code analysis
- name: code-analysis
image: maven:3-eclipse-temurin-17
commands:
- mvn sonar:sonar --no-transfer-progress -Dsonar.projectKey=$SONAR_PROJECT_KEY -Dsonar.host.url=$SONAR_INSTANCE_URL -Dsonar.login=$SONAR_LOGIN_KEY -B -V
environment:
SONAR_PROJECT_KEY:
from_secret: sonar_project_key
SONAR_INSTANCE_URL:
from_secret: sonar_instance_url
SONAR_LOGIN_KEY:
from_secret: sonar_login_key

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
application-*.log
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/

21
pom.xml
View File

@@ -6,7 +6,7 @@
<groupId>wtf.beatrice</groupId>
<artifactId>autosqueal</artifactId>
<version>1.0-SNAPSHOT</version>
<version>0.0.5-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
@@ -61,4 +61,23 @@
</plugins>
</build>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2/</url>
</repository>
<repository>
<id>sonatype-nexus-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>sonatype-nexus-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</pluginRepository>
</pluginRepositories>
</project>

38
readme.md Normal file
View File

@@ -0,0 +1,38 @@
# [autosqueal](https://git.beatrice.wtf/Tools/autosqeal)
[![Build Status](https://drone.beatrice.wtf/api/badges/Tools/autosqeal/status.svg?ref=refs/heads/main)](https://drone.beatrice.wtf/Tools/autosqeal)
[![Quality Gate Status](https://sonar.beatrice.wtf/api/project_badges/measure?project=autosqueal&metric=alert_status&token=sqb_49dde556c032d0130640ea1e48875905b158d368)](https://sonar.beatrice.wtf/dashboard?id=autosqueal)
[![Reliability Rating](https://sonar.beatrice.wtf/api/project_badges/measure?project=autosqueal&metric=reliability_rating&token=sqb_49dde556c032d0130640ea1e48875905b158d368)](https://sonar.beatrice.wtf/dashboard?id=autosqueal)
[![Security Rating](https://sonar.beatrice.wtf/api/project_badges/measure?project=autosqueal&metric=security_rating&token=sqb_49dde556c032d0130640ea1e48875905b158d368)](https://sonar.beatrice.wtf/dashboard?id=autosqueal)
[![Maintainability Rating](https://sonar.beatrice.wtf/api/project_badges/measure?project=autosqueal&metric=sqale_rating&token=sqb_49dde556c032d0130640ea1e48875905b158d368)](https://sonar.beatrice.wtf/dashboard?id=autosqueal)
[![Lines of Code](https://sonar.beatrice.wtf/api/project_badges/measure?project=autosqueal&metric=ncloc&token=sqb_49dde556c032d0130640ea1e48875905b158d368)](https://sonar.beatrice.wtf/dashboard?id=autosqueal)
*little java tool to automatically perform mouse actions*
## supported systems
| system | support |
|-----------|------------|
| macOS | ✅ **full** |
| Windows | 🟠 limited |
| GNU/Linux | 🟠 limited |
## building
**required tools**
- java 17 sdk
- git
- maven
**build steps**
1. clone the official repository linked below using `git clone`.
2. `cd` into the directory and run `mvn clean package`.
3. you will find a runnable jar with dependencies in the `target/` folder.
4. run the built jar file with `java -jar target/autosqueal-*-dependencies.jar`.
## support
| category | info |
|---------------------|---------------------------------------------------------------|
| official repository | [gitea src](https://git.beatrice.wtf/Tools/autosqeal.git) |
| mirror repository | [github src](https://github.com/mind-overflow/autosqueal.git) |
| build status | [drone-ci](https://drone.beatrice.wtf/Tools/autosqeal) |
| dev email | [hello@beatrice.wtf](mailto:hello@beatrice.wtf) |

View File

@@ -4,65 +4,26 @@ import com.github.kwhat.jnativehook.GlobalScreen;
import com.github.kwhat.jnativehook.NativeHookException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import wtf.beatrice.autosqueal.listener.CursorMoveListener;
import wtf.beatrice.autosqueal.listener.KeyPressListener;
import wtf.beatrice.autosqueal.ui.MainWindow;
import java.awt.*;
import java.awt.event.InputEvent;
import java.util.Random;
import java.util.Timer;
public class Main {
private static final int LOOPS_BEFORE_CLICK = 5;
private static final int TIME_BETWEEN_MOVES = 5;
private static final Logger LOGGER = LogManager.getLogger(Main.class);
private static final MainWindow mainWindow = new MainWindow();
public static void main(String[] args) throws InterruptedException, AWTException {
public static void main(String[] args) {
LOGGER.info("Hello world!");
registerJNativeHook();
mainWindow.init();
Timer timer = new Timer();
Timer timerRunner = new Timer();
CursorMoveListener cursorMoveListener = new CursorMoveListener();
timer.schedule(cursorMoveListener, 0L, 1000L);
int height = Toolkit.getDefaultToolkit().getScreenSize().height;
int width = Toolkit.getDefaultToolkit().getScreenSize().width;
Random random = new Random();
while (true) {
//if(!cursorMoveListener.isUserAway()) continue;
for(int i = 0; i < LOOPS_BEFORE_CLICK; i++) {
int currentX = MouseInfo.getPointerInfo().getLocation().x;
int currentY = MouseInfo.getPointerInfo().getLocation().y;
LOGGER.info("Starting coordinates: {}, {}", currentX, currentY);
int randomX, randomY;
randomX = random.nextInt(width);
randomY = random.nextInt(height);
LOGGER.info("Destination coordinates: {}, {}", randomX, randomY);
startMover(randomX, randomY);
}
startMover(width - 5, 5);
Robot robot = new Robot();
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
Thread.sleep(200);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
Thread.sleep(500);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
Thread.sleep(200);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
Thread.sleep(200);
}
timerRunner.schedule(cursorMoveListener, 0L, 1000L);
}
private static void registerJNativeHook() {
@@ -80,16 +41,8 @@ public class Main {
}
}
private static void startMover(int destX, int destY) throws InterruptedException {
Timer timer = new Timer();
CursorMover cursorMover = new CursorMover(destX, destY);
timer.schedule(cursorMover, 0L, 2L);
while (cursorMover.isRunning()) {
Thread.sleep(200);
}
timer.cancel();
Thread.sleep(TIME_BETWEEN_MOVES * 1000);
public static MainWindow getMainWindow() {
return mainWindow;
}
}

View File

@@ -0,0 +1,77 @@
package wtf.beatrice.autosqueal.controls;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import wtf.beatrice.autosqueal.util.RunnerUtil;
import java.awt.*;
import java.security.SecureRandom;
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;
public class CursorMover extends TimerTask
{
private static final Logger LOGGER = LogManager.getLogger(CursorMover.class);
private final Random random;
private SingleStepMovementTask singleStepMovementTask;
private static final int LOOPS_BEFORE_CLICK = 5;
private int iteration = 0;
public CursorMover() {
random = new SecureRandom();
singleStepMovementTask = null;
}
@Override
public void run() {
int currentX = MouseInfo.getPointerInfo().getLocation().x;
int currentY = MouseInfo.getPointerInfo().getLocation().y;
LOGGER.info("Starting coordinates: {}, {}", currentX, currentY);
int destX;
int destY;
if (iteration == LOOPS_BEFORE_CLICK) {
destX = RunnerUtil.SCREEN_WIDTH - 5;
destY = 5;
try {
singleStepMovementTask = new SingleStepMovementTask(destX, destY, true);
} catch (AWTException e) {
LOGGER.error(e);
return;
}
iteration = 0;
} else {
destX = random.nextInt(RunnerUtil.SCREEN_WIDTH);
destY = random.nextInt(RunnerUtil.SCREEN_HEIGHT);
try {
singleStepMovementTask = new SingleStepMovementTask(destX, destY, false);
} catch (AWTException e) {
LOGGER.error(e);
return;
}
iteration++;
}
LOGGER.info("Destination coordinates: {}, {}", destX, destY);
Timer timer = new Timer();
timer.schedule(singleStepMovementTask, 0L, 2L);
}
public boolean isRunning() {
if (singleStepMovementTask == null) return false;
return singleStepMovementTask.isRunning();
}
}

View File

@@ -1,24 +1,32 @@
package wtf.beatrice.autosqueal;
package wtf.beatrice.autosqueal.controls;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.awt.*;
import java.awt.event.InputEvent;
import java.util.TimerTask;
public class CursorMover extends TimerTask {
public class SingleStepMovementTask extends TimerTask {
private static final Logger LOGGER = LogManager.getLogger(CursorMover.class);
private static final Logger LOGGER = LogManager.getLogger(SingleStepMovementTask.class);
final int destX, destY;
final int destX;
final int destY;
final Robot robot;
float currentX, currentY;
float stepX = 1, stepY = 1;
boolean isRunning = true;
float currentX;
float currentY;
float stepX = 1;
float stepY = 1;
private boolean isRunning = true;
boolean click;
public CursorMover(int destinationX, int destinationY) {
public SingleStepMovementTask(int destinationX, int destinationY, boolean click) throws AWTException {
this.click = click;
currentX = MouseInfo.getPointerInfo().getLocation().x;
currentY = MouseInfo.getPointerInfo().getLocation().y;
@@ -26,7 +34,8 @@ public class CursorMover extends TimerTask {
destX = destinationX;
destY = destinationY;
int lengthX, lengthY;
int lengthX;
int lengthY;
lengthX = Math.round(Math.abs(currentX - destX));
lengthY = Math.round(Math.abs(currentY - destY));
@@ -43,11 +52,7 @@ public class CursorMover extends TimerTask {
LOGGER.info("Len: [{}, {}]", lengthX, lengthY);
LOGGER.info("Step: [{}, {}]", stepX, stepY);
try {
robot = new Robot();
} catch (AWTException e) {
throw new RuntimeException(e);
}
robot = new Robot();
}
@@ -62,6 +67,24 @@ public class CursorMover extends TimerTask {
}
if(destX == Math.round(currentX) || destY == Math.round(currentY)) {
if (click) {
try {
Thread.sleep(500);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
Thread.sleep(200);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
Thread.sleep(500);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
Thread.sleep(200);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
Thread.sleep(200);
} catch (InterruptedException e) {
LOGGER.error(e);
Thread.currentThread().interrupt();
}
}
LOGGER.info("Reached destination, stopping mover timer");
LOGGER.info("Dest: [{}, {}], Curr: [{}, {}]", destX, destY, currentX, currentY);
isRunning = false;

View File

@@ -1,15 +1,18 @@
package wtf.beatrice.autosqueal;
package wtf.beatrice.autosqueal.listener;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import wtf.beatrice.autosqueal.Main;
import wtf.beatrice.autosqueal.util.RunnerUtil;
import java.awt.*;
import java.util.TimerTask;
public class CursorMoveListener extends TimerTask {
private int oldX, oldY;
private int newX, newY;
private int oldX;
private int oldY;
private int loops;
private boolean isUserAway;
@@ -24,22 +27,25 @@ public class CursorMoveListener extends TimerTask {
@Override
public void run() {
newX = MouseInfo.getPointerInfo().getLocation().x;
newY = MouseInfo.getPointerInfo().getLocation().y;
if(RunnerUtil.isSquealing()) return;
int newX = MouseInfo.getPointerInfo().getLocation().x;
int newY = MouseInfo.getPointerInfo().getLocation().y;
if(newX != oldX || newY != oldY) {
// cursor has been moved
loops = 0;
LOGGER.info("User is no longer away!");
} else {
if (loops < 30) {
if (loops < 10) {
loops++;
} else {
LOGGER.info("User is away!");
Main.getMainWindow().toggleRunning();
}
}
isUserAway = loops >= 30;
isUserAway = loops >= 10;
oldX = newX;
oldY = newY;

View File

@@ -1,4 +1,4 @@
package wtf.beatrice.autosqueal;
package wtf.beatrice.autosqueal.listener;
import com.github.kwhat.jnativehook.GlobalScreen;
import com.github.kwhat.jnativehook.NativeHookException;
@@ -6,6 +6,7 @@ import com.github.kwhat.jnativehook.keyboard.NativeKeyEvent;
import com.github.kwhat.jnativehook.keyboard.NativeKeyListener;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import wtf.beatrice.autosqueal.Main;
import java.util.ArrayList;
import java.util.List;
@@ -13,8 +14,9 @@ import java.util.List;
public class KeyPressListener implements NativeKeyListener
{
private static final Logger LOGGER = LogManager.getLogger(KeyPressListener.class);
private final static List<Integer> pressedKeysIds = new ArrayList<>();
private static final List<Integer> pressedKeysIds = new ArrayList<>();
@Override
public void nativeKeyPressed(NativeKeyEvent e) {
LOGGER.info("Key Pressed: {}", NativeKeyEvent.getKeyText(e.getKeyCode()));
@@ -22,7 +24,7 @@ public class KeyPressListener implements NativeKeyListener
try {
GlobalScreen.unregisterNativeHook();
} catch (NativeHookException nativeHookException) {
nativeHookException.printStackTrace();
LOGGER.error("Failed to unregister native hook", nativeHookException);
}
}
@@ -31,6 +33,7 @@ public class KeyPressListener implements NativeKeyListener
handlePressedKeys();
}
@Override
public void nativeKeyReleased(NativeKeyEvent e) {
LOGGER.info("Key Released: {}", NativeKeyEvent.getKeyText(e.getKeyCode()));
@@ -44,13 +47,11 @@ public class KeyPressListener implements NativeKeyListener
pressedKeysIds.contains(NativeKeyEvent.VC_CONTROL)) {
StringBuilder keys = new StringBuilder();
pressedKeysIds.forEach(keyCode -> {
keys.append("[").append(NativeKeyEvent.getKeyText(keyCode)).append("]");
});
pressedKeysIds.forEach(keyCode -> keys.append("[").append(NativeKeyEvent.getKeyText(keyCode)).append("]"));
LOGGER.warn("Received shutdown keystroke: {}", keys);
System.exit(0);
Main.getMainWindow().toggleRunning();
}
}
}

View File

@@ -0,0 +1,142 @@
package wtf.beatrice.autosqueal.ui;
import com.github.kwhat.jnativehook.keyboard.NativeKeyEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import wtf.beatrice.autosqueal.controls.CursorMover;
import wtf.beatrice.autosqueal.listener.CursorMoveListener;
import wtf.beatrice.autosqueal.util.RunnerUtil;
import wtf.beatrice.autosqueal.util.SystemUtil;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.Timer;
public class MainWindow
{
private static final Logger LOGGER = LogManager.getLogger(MainWindow.class);
private static final int WINDOW_HEIGHT = 700;
private static final int WINDOW_WIDTH = 800;
private Timer timerRunner = new Timer();
private CursorMover cursorMover = new CursorMover();
private Button toggleButton;
public void init() {
JFrame frame = new JFrame();
frame.setSize(new Dimension(WINDOW_WIDTH, WINDOW_HEIGHT));
frame.setTitle("autosqueal");
frame.setResizable(false);
toggleButton = new Button();
toggleButton.setBounds(new Rectangle((WINDOW_WIDTH / 2) - 60, WINDOW_HEIGHT - 60, 120, 30));
toggleButton.addActionListener(e -> toggleRunning());
frame.add(toggleButton);
toggleRunning();
int bordersPx = 10;
int rescaleRateo = ((WINDOW_WIDTH - (2 * bordersPx)) * 100) / RunnerUtil.SCREEN_WIDTH;
int rescaleWidth = RunnerUtil.SCREEN_WIDTH * rescaleRateo / 100;
int rescaleHeight = RunnerUtil.SCREEN_HEIGHT * rescaleRateo / 100;
JLabel imageLabel = new JLabel(new ImageIcon(getScreenCapture(rescaleWidth, rescaleHeight)));
imageLabel.setBounds(new Rectangle(bordersPx, bordersPx, rescaleWidth, rescaleHeight));
frame.add(imageLabel);
Image preciseScreenshot = getPreciseScreenshot();
JLabel timestampLabel = new JLabel(new ImageIcon(preciseScreenshot));
timestampLabel.setBounds(new Rectangle(bordersPx, bordersPx + rescaleHeight + bordersPx, 100, 30));
frame.add(timestampLabel);
frame.setLayout(null);
frame.setVisible(true);
}
private Image getScreenCapture(int rescaleWidth, int rescaleHeight) {
Image fullImage = getScreenCapture();
return fullImage.getScaledInstance(rescaleWidth, rescaleHeight, Image.SCALE_FAST);
}
public Image getPreciseScreenshot() {
if(SystemUtil.getHostSystem().equals(SystemUtil.OperatingSystem.MAC_OS)) {
BufferedImage screenshot = getScreenCapture();
return screenshot.getSubimage(RunnerUtil.SCREEN_WIDTH - 100,0, 100, 30);
}
return null;
}
public BufferedImage getScreenCapture() {
try {
Robot robot = new Robot();
return robot.createScreenCapture(new Rectangle(RunnerUtil.SCREEN_WIDTH, RunnerUtil.SCREEN_HEIGHT));
} catch (AWTException e) {
LOGGER.error("Robot initialization error", e);
}
return null;
}
public BufferedImage getBufferedImage(Image img) {
if (img instanceof BufferedImage image)
{
return image;
}
// Create a buffered image with transparency
BufferedImage bimage = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_ARGB);
// Draw the image on to the buffered image
Graphics2D bGr = bimage.createGraphics();
bGr.drawImage(img, 0, 0, null);
bGr.dispose();
// Return the buffered image
return bimage;
}
public void toggleRunning() {
String label;
if (cursorMover == null) {
timerRunner = new Timer();
cursorMover = new CursorMover();
timerRunner.schedule(cursorMover, 1000L, RunnerUtil.SECONDS_BETWEEN_MOVES * 1000L);
label = "Stop [" +
NativeKeyEvent.getKeyText(NativeKeyEvent.VC_CONTROL) +
"][" +
NativeKeyEvent.getKeyText(NativeKeyEvent.VC_ALT) +
"]";
}
else {
timerRunner.cancel();
cursorMover = null;
label = "Start [" +
NativeKeyEvent.getKeyText(NativeKeyEvent.VC_CONTROL) +
"][" +
NativeKeyEvent.getKeyText(NativeKeyEvent.VC_ALT) +
"]";
}
toggleButton.setLabel(label);
}
@Deprecated
public boolean isRunning() {
if (cursorMover == null)
return false;
return cursorMover.isRunning();
}
}

View File

@@ -0,0 +1,22 @@
package wtf.beatrice.autosqueal.util;
import wtf.beatrice.autosqueal.Main;
import java.awt.*;
public class RunnerUtil {
private RunnerUtil() {
throw new AssertionError("The RunnerUtil class is not intended to be instantiated.");
}
public static final int SECONDS_BETWEEN_MOVES = 10;
public static final int SCREEN_HEIGHT = Toolkit.getDefaultToolkit().getScreenSize().height;
public static final int SCREEN_WIDTH = Toolkit.getDefaultToolkit().getScreenSize().width;
public static boolean isSquealing() {
return Main.getMainWindow().isRunning();
}
}

View File

@@ -0,0 +1,26 @@
package wtf.beatrice.autosqueal.util;
import java.util.Locale;
public class SystemUtil
{
public static OperatingSystem getHostSystem() {
String osName = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
if (osName.contains("win")) {
return OperatingSystem.WINDOWS;
} else if (osName.contains("nix") ||
osName.contains("nux") ||
osName.contains("aix")) {
return OperatingSystem.LINUX;
} else if (osName.contains("mac")) {
return OperatingSystem.MAC_OS;
} else {
return OperatingSystem.UNKNOWN;
}
}
public enum OperatingSystem {
WINDOWS, LINUX, MAC_OS, UNKNOWN;
}
}