Skip to content

Commit

Permalink
Merge pull request #20 from Rutger505/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Rutger505 authored Nov 2, 2023
2 parents 316e1fc + c9932d9 commit b27f8e8
Show file tree
Hide file tree
Showing 19 changed files with 212 additions and 121 deletions.
1 change: 0 additions & 1 deletion .idea/artifacts/Useful_Autoclicker.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions .idea/libraries/mslinks_1_1_0.xml

This file was deleted.

19 changes: 13 additions & 6 deletions .idea/sonarlint/issuestore/index.pb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 13 additions & 6 deletions .idea/sonarlint/securityhotspotstore/index.pb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 12 additions & 6 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 21 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,34 @@
# Useful Autoclicker

## Powerful Autoclicker with great features
A versatile Autoclicker for various applications.

![Screenshot of Autoclicker](https://user-images.githubusercontent.com/119070855/232733386-f12beb46-be38-4c62-9a4d-d5b51dbf9995.png)
![image](https://github.com/Rutger505/Useful-Autoclicker/assets/119070855/3fc634ab-53f0-48e1-b8c3-8c0d98fda2a5)

## Features

* Both click and hold down the mouse button
* Control timings mentioned above.
* Randomize the timings.
* Randomize timings.
* Start the autoclicker by using a hotkey on your keyboard.
* Change the hotkey button.
* 5 buttons for autoclicking: left, middle, right, and the 2 side buttons.
* Limit the number of clicks to a certain amount.
* Autoclick when the button is pressed.
* Autoclick when the seleced mouse button in pressed.

## How to download
## Downloading Autoclicker

### Downloading <ins>without</ins> Java installed
1. Download and install Java [here](https://www.java.com/). Already have Java? Skip this step.
2. Click on the latest release on the right side
![image](https://github.com/Rutger505/Useful-Autoclicker/assets/119070855/ab7729f1-3555-4802-9683-0dd692452e11)
3. Click on the file "Useful-Autoclicker.jar"
![image](https://github.com/Rutger505/Useful-Autoclicker/assets/119070855/f9b55088-b41d-4c43-803a-b3b55a527aca)
4. Open your new Autoclicker!

* Install Java SE from [Java JDK](https://www.oracle.com/java/technologies/downloads/#jdk21-windows)
* Choose your correct operating system and download the installer
* Click on the latest release on the right side
* Click on the file "Useful-Autoclicker.jar"
* Open your new Autoclicker!
## Problems & Solutions

### Downloading <ins>with</ins> Java installed
### Download the latest version of Java

* Click on the latest release on the right side
* Click on the file "Useful-Autoclicker.jar"
* Open your new Autoclicker!

## Not starting? try the following steps:

### Downloading the newest version of Java

download and install [Java JDK](https://www.oracle.com/java/technologies/downloads/#jdk21-windows)
1. Go to the [Java website](https://www.java.com/) and download and install Java again.

### Run the file using terminal

Expand All @@ -46,16 +39,11 @@ download and install [Java JDK](https://www.oracle.com/java/technologies/downloa
java -jar "Useful-Autoclicker.jar"
```

### Setting the correct java path

1. Right click the autoclicker and click open width.
2. Click "choose another app".
3. Click "Choose an app on this PC".
4. Go to your programFiles located in the windows drive(usually C:).
5. Click "java".
6. Click "jre".
7. Click "bin".
8. Click "javaw.exe".
9. Click ok.
10. If this does not work, try the same steps but select the JDK this time.
### Opening with Java

1. Right click the Useful-Autoclicker file.
2. Click "Open with".
3. Click "Choose another app".
2. Click "Java(TM) Plantform SE Binary".
3. Click "Always".

4 changes: 3 additions & 1 deletion Useful-Autoclicker.iml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="jnativehook-2.2.2" level="project" />
<orderEntry type="library" name="mslinks-1.1.0" level="project" />
</component>
<component name="SonarLintModuleSettings">
<option name="uniqueId" value="9ed15a99-7f4f-41db-946e-936a540a43a6" />
</component>
</module>
Binary file removed libraries/mslinks-1.1.0.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion src/Autoclicker.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public boolean isRunning() {
}

public void start() {
Logger.trace("Starting Autoclicker");
Logger.info("Starting Autoclicker");
autoclickerThread = new Thread(this::autoclickerMain);
autoclickerThread.start();
}
Expand Down
5 changes: 3 additions & 2 deletions src/GUI/GUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import resources.Constants;
import settings.Settings;
import settings.Settings;
import utils.Logger;

import javax.swing.*;
import javax.swing.border.Border;
Expand All @@ -14,7 +14,7 @@
public class GUI extends JFrame {

// title/version
private static final double AUTOCLICKER_VERSION = 2.1;
private static final double AUTOCLICKER_VERSION = 2.2;
public static final String MAIN_FRAME_TITLE = "Useful Autoclicker " + AUTOCLICKER_VERSION;

// components
Expand All @@ -34,6 +34,7 @@ public class GUI extends JFrame {
* Makes GUI
*/
public GUI() {
Logger.trace("Starting GUI");
JComponentFactory components = new JComponentFactory();
Settings settings = Settings.getInstance();

Expand Down
4 changes: 3 additions & 1 deletion src/InputListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.github.kwhat.jnativehook.mouse.NativeMouseEvent;
import com.github.kwhat.jnativehook.mouse.NativeMouseListener;
import settings.Settings;
import utils.ApplicationDirectory;
import utils.FileVisibility;
import utils.Logger;

Expand All @@ -28,6 +29,7 @@ public class InputListener implements NativeKeyListener, NativeMouseListener {
* @param gui GUI for making components
*/
public InputListener(GUI gui) {
Logger.trace("Starting InputListener");
this.gui = gui;
this.clicker = new Autoclicker(this);
this.settings = Settings.getInstance();
Expand Down Expand Up @@ -207,7 +209,7 @@ public void remove(DocumentFilter.FilterBypass fb, int offset, int length) throw
GlobalScreen.addNativeMouseListener(this);

// hide JNativeHook file
FileVisibility.changeVisibility("JNativeHook.x86_64.dll", true);
FileVisibility.changeVisibility(ApplicationDirectory.getApplicationDirectory() + "JNativeHook.x86_64.dll", true);
}

/**
Expand Down
12 changes: 3 additions & 9 deletions src/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import utils.OneInstance;
import utils.StartMenuShortcut;

import static utils.ApplicationDirectory.getApplicationDirectory;

public class Main {
/**
* Starts the program
Expand All @@ -12,20 +14,12 @@ public class Main {
*/
public static void main(String[] args) {

// CLASSES REORDER

Logger.trace("Activating OneInstance");
OneInstance.Activate();
Logger.trace("Getting Settings from file");
SaveSettings.initialize();
StartMenuShortcut.createStartMenuShortcut();

Logger.trace("Making start menu shortcut");
new StartMenuShortcut();

Logger.trace("Starting GUI");
GUI gui = new GUI();

Logger.trace("Starting InputListener");
new InputListener(gui);
}
}
15 changes: 9 additions & 6 deletions src/settings/SaveSettings.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package settings;

import utils.ApplicationDirectory;
import utils.FileVisibility;
import utils.Logger;

Expand All @@ -10,6 +11,7 @@

public class SaveSettings {
private static final String SETTING_FILE_NAME = "settings";
private static final String SETTING_FILE_ABSOLUTE_PATH = ApplicationDirectory.getApplicationDirectory() + SETTING_FILE_NAME;

private SaveSettings() {
throw new IllegalStateException("Utility class");
Expand All @@ -19,6 +21,7 @@ private SaveSettings() {
* Tries to load data from settings file.
*/
public static void initialize() {
Logger.trace("Getting Settings from file");
getSettings();
saveSettings(); // so the settings file is created if it doesn't exist yet.
}
Expand All @@ -29,9 +32,9 @@ public static void initialize() {
*/
private static void getSettings() {
try {
FileVisibility.changeVisibility(SETTING_FILE_NAME, false);
FileVisibility.changeVisibility(SETTING_FILE_ABSOLUTE_PATH, false);

FileInputStream fileIn = new FileInputStream(SETTING_FILE_NAME);
FileInputStream fileIn = new FileInputStream(SETTING_FILE_ABSOLUTE_PATH);
ObjectInputStream in = new ObjectInputStream(fileIn);
Settings loadedSettings = (Settings) in.readObject();

Expand All @@ -40,7 +43,7 @@ private static void getSettings() {
} catch (Exception e) {
Logger.warn("No compatible settings file found " + e);
} finally {
FileVisibility.changeVisibility(SETTING_FILE_NAME, true);
FileVisibility.changeVisibility(SETTING_FILE_ABSOLUTE_PATH, true);
}
}

Expand All @@ -49,17 +52,17 @@ private static void getSettings() {
*/
public static void saveSettings() {
try {
FileVisibility.changeVisibility(SETTING_FILE_NAME, false);
FileVisibility.changeVisibility(SETTING_FILE_ABSOLUTE_PATH, false);

FileOutputStream fileOut = new FileOutputStream(SETTING_FILE_NAME);
FileOutputStream fileOut = new FileOutputStream(SETTING_FILE_ABSOLUTE_PATH);
ObjectOutputStream out = new ObjectOutputStream(fileOut);
out.writeObject(Settings.getInstance());

Logger.info("Settings saved");
} catch (Exception e) {
Logger.error("Settings could not be saved " + e);
} finally {
FileVisibility.changeVisibility(SETTING_FILE_NAME, true);
FileVisibility.changeVisibility(SETTING_FILE_ABSOLUTE_PATH, true);
}
}
}
25 changes: 25 additions & 0 deletions src/utils/ApplicationDirectory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package utils;

import java.io.File;

public class ApplicationDirectory {

private ApplicationDirectory() {
throw new IllegalStateException("Utility class");
}

private static String applicationDirectory = null;

public static String getApplicationDirectory() {
if (applicationDirectory == null) {
try {
applicationDirectory = new File(StartMenuShortcut.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()).getParentFile().getPath() + "\\";
Logger.info("Application directory: " + applicationDirectory);
} catch (Exception e) {
Logger.error("Failed getting application path " + e);
}
}

return applicationDirectory;
}
}
2 changes: 1 addition & 1 deletion src/utils/FileVisibility.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void changeVisibility(String filename, boolean hidden) {

Logger.info(filename + " is now " + (hidden ? "hidden" : "visible"));
} catch (IOException e) {
Logger.warn("(FileHider) " + filename + " could not be hidden");
Logger.error(filename + " could not be hidden " + e);
}
}
}
Loading

0 comments on commit b27f8e8

Please sign in to comment.