Compare commits

...

3 Commits
v3.2 ... master

Author SHA1 Message Date
MrBesen 8431ace7ef
moved to maven 2021-02-22 21:17:17 +01:00
MrBesen 569d3aaf81
Merge pull request #7 from mrbesen/dev
fileselector menu
2018-01-05 22:30:06 +01:00
mrbesen d75a454981 fileselector menu 2018-01-05 22:29:15 +01:00
10 changed files with 111 additions and 32 deletions

4
.gitignore vendored
View File

@ -2,4 +2,6 @@
export.jardesc
.project
.classpath
.profile
.profile
/default.profile
target/

View File

@ -22,11 +22,11 @@ Bot losses some matches -> Bot gets easyer oponents -> Bot winns some matches (A
This java Apllication needs some kind of Mobile Device Emulator or Interface.
I have tested it with Teamviewer and Nox Appplayer. You can configure points of the Clashroyale app, where the bot automatically clicks.
These clicks can cause Troops to spawn or Buttons to be Pressed.
## Video:
## Video (a bit outdated):
[![Video](https://i.vimeocdn.com/video/641445132_640.jpg)](https://vimeo.com/222811186 "Video")
#### How does it work?
This program emulates a mouse and keyboard and controls your computer with that emulated hardware. To The App it look, like you are a normal User.
This program emulates a mouse and keyboard and controls your computer with that emulated hardware. To The App it look, like you are a normal user.
#### Features:
* Automated Backfocus

46
pom.xml Normal file
View File

@ -0,0 +1,46 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.mrbesen</groupId>
<artifactId>clashroyalebot</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>clashroyalebot</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
<dependencies>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>de.mrbesen.cr.auto.clicker.Main</mainClass>
</manifest>
<manifestEntries>
<Class-Path>.</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,4 +1,4 @@
package mrbesen.cr.auto.clicker;
package de.mrbesen.cr.auto.clicker;
import java.awt.AWTException;
import java.awt.Color;
@ -34,7 +34,7 @@ public class Clicker implements Runnable{
private int randomness = 15;
private boolean paused = false;
private boolean backfocus = false;
private final int waittime = 50;//time between mouse teleports and clicks
private final int waittime = 250;//time between mouse teleports and clicks
private int mincolordistance = 35;
private Overlay ov = null;

View File

@ -1,4 +1,4 @@
package mrbesen.cr.auto.clicker;
package de.mrbesen.cr.auto.clicker;
public class Main {

View File

@ -1,4 +1,4 @@
package mrbesen.cr.auto.clicker;
package de.mrbesen.cr.auto.clicker;
import java.awt.Color;
import java.awt.Graphics;

View File

@ -1,4 +1,4 @@
package mrbesen.cr.auto.clicker;
package de.mrbesen.cr.auto.clicker;
import java.util.Random;

View File

@ -1,4 +1,4 @@
package mrbesen.cr.auto.clicker;
package de.mrbesen.cr.auto.clicker;
import java.awt.AWTException;
import java.awt.Color;

View File

@ -1,4 +1,4 @@
package mrbesen.cr.auto.clicker;
package de.mrbesen.cr.auto.clicker;
import java.awt.Color;
@ -11,6 +11,7 @@ public class PosSelector implements Runnable {
UI ui;
private boolean required;
public boolean isRequired() {
return required;
}

View File

@ -1,4 +1,4 @@
package mrbesen.cr.auto.clicker;
package de.mrbesen.cr.auto.clicker;
import java.awt.Color;
import java.awt.Dimension;
@ -13,6 +13,7 @@ import java.util.Scanner;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
@ -23,8 +24,7 @@ import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import com.sun.istack.internal.Nullable;
import javax.swing.filechooser.FileNameExtensionFilter;
public class UI implements ActionListener {
@ -68,6 +68,8 @@ public class UI implements ActionListener {
private JLabel info = new JLabel("Define positions, to start.");
private JLabel time = new JLabel("0 s");
private JFileChooser filechooser = new JFileChooser();
private Slider[] slider = {
new Slider("Waittime: ","s", 1,300,180,-1, null, new Updater() {
@Override
@ -82,12 +84,8 @@ public class UI implements ActionListener {
}
},false)
};
Clicker bot = new Clicker();
private File file = new File(".profile");
Clicker bot = new Clicker();
public UI() {
Main.get().ui = this;
@ -153,7 +151,7 @@ public class UI implements ActionListener {
frame.setVisible(true);
//set tooltips
start.setToolTipText("Starts the Bot.");
start.setToolTipText("Starts the Bot. (When gray, try to set the positions for the red buttons!)");
skip.setToolTipText("Skips the current Action.(Waiting or beeing in a match, only usefull, when the bot miss clicked somewhere)");
pause.setToolTipText("Pauses the \"output\" of the Bot, but the internal states are still updated.");
exit.setToolTipText("Stops the Bot and closes the Window.");
@ -173,6 +171,8 @@ public class UI implements ActionListener {
posselctors[6].button.setToolTipText("Set the Position, where a Card should be placed. Leave it empty to use the same position as the \"Battle\" position.");
posselctors[7].button.setToolTipText("Set the position of the Close button, of the menue that po up, when you tap the arena. This one also saves the color of the position to auto detect it.");
filechooser.removeChoosableFileFilter(filechooser.getAcceptAllFileFilter());
filechooser.addChoosableFileFilter(new FileNameExtensionFilter("Botsettings", "profile"));
}
@Override
@ -207,6 +207,7 @@ public class UI implements ActionListener {
else if(srcb.equals(exit)) {
bot.stop();
frame.setVisible(false);
frame.dispose();
System.exit(0);
} else if(srcb.equals(pause)) {
if(bot.isPaused()) {//the bot is going to be unpaused
@ -223,9 +224,18 @@ public class UI implements ActionListener {
} else if(src instanceof JMenuItem) {
JMenuItem srcI = (JMenuItem) src;
if(srcI.equals(load)) {
load(true);
int returnval = filechooser.showOpenDialog(frame);
if(returnval == JFileChooser.APPROVE_OPTION) {
File f = filechooser.getSelectedFile();
load(f, true);
} else
info("cancled.");
} else if(srcI.equals(save)) {
save();
int returnval = filechooser.showOpenDialog(frame);
if(returnval == JFileChooser.APPROVE_OPTION) {
save(filechooser.getSelectedFile());
} else
info("cancled.");
} else if(srcI.equals(new_)) {
new_();
}
@ -244,10 +254,10 @@ public class UI implements ActionListener {
}
}
private void load(boolean info) {
if(file.exists()) {
private void load(File f, boolean info) {
if(f.exists()) {
try {
Scanner s = new Scanner(file);
Scanner s = new Scanner(f);
while(s.hasNextLine()) {
String split[] = s.nextLine().split(" ");
if(!split[1].equals("null")) {
@ -289,11 +299,11 @@ public class UI implements ActionListener {
info("no profile found.");
}
private void save() {
private void save(File f) {
try {
if(!file.exists())
file.createNewFile();
else {
if(!f.getName().endsWith(".profile"))
f = new File(f.getAbsoluteFile() + ".profile");
if(f.exists()){
/*ok == 0
cancel = 2*/
int choose = JOptionPane.showConfirmDialog(null, "You are going to override the old profile!", "Override", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
@ -302,9 +312,10 @@ public class UI implements ActionListener {
return;
}
}
} else
f.createNewFile();
FileWriter fw = new FileWriter(file);
FileWriter fw = new FileWriter(f);
fw.write(bot.serialize()+"\n101 "+ slider[0].getValue() + "\n102 " + doubleplace.isSelected()+"\n103 " + slider[1].getValue());
fw.flush();
fw.close();
@ -325,6 +336,17 @@ public class UI implements ActionListener {
bot.stop();
bot = null;
bot = new Clicker();
//set all buttons to red
start.setEnabled(false);
skip.setEnabled(false);
for(PosSelector poss : posselctors) {
poss.red();
}
for(Slider s : slider) {
s.reset();
}
}
public void refresh() {
@ -447,7 +469,7 @@ public class UI implements ActionListener {
private static final long serialVersionUID = 1L;
private JSlider slider;
private JLabel label;
private int defaultvalue;
private ChangeListener listener;
private Updater updater;
private String prefix = "", sufix = "";
@ -460,7 +482,7 @@ public class UI implements ActionListener {
* @param startvalue inital value
* @param komma 10^x offset for komma digits
*/
public Slider(String prefix, String sufix, int minvalue, int maxvalue, int startvalue, int komma, @Nullable ChangeListener cl,@Nullable Updater upd, boolean enabled) {//ChangeListener or Updater could be Null!
public Slider(String prefix, String sufix, int minvalue, int maxvalue, int startvalue, int komma, ChangeListener cl, Updater upd, boolean enabled) {//ChangeListener or Updater could be Null!
slider = new JSlider(minvalue, maxvalue, startvalue);
slider.addChangeListener(this);
if(prefix != null)
@ -475,6 +497,7 @@ public class UI implements ActionListener {
listener = cl;
updater = upd;
slider.setEnabled(enabled);
defaultvalue = startvalue;
}
public int getValue() {
@ -504,5 +527,12 @@ public class UI implements ActionListener {
if(updater != null)
updater.update(slider.getValue());
}
/**
* Restores the default value, does not change the controlled value, just the displayed one
*/
public void reset() {
setValue(defaultvalue);
}
}
}