first commit

This commit is contained in:
Akito123321 2024-05-24 07:02:30 +02:00
commit 511de720d3
42 changed files with 439 additions and 0 deletions

40
.classpath Normal file
View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

23
.project Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>macro</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8

View File

@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

BIN
Images/test.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 KiB

BIN
Traindata/eng.traineddata Normal file

Binary file not shown.

View File

@ -0,0 +1 @@
tessedit_create_alto 1

View File

@ -0,0 +1 @@
tessedit_zero_rejection T

View File

@ -0,0 +1,4 @@
load_system_dawg F
load_freq_dawg F
user_words_suffix user-words
user_patterns_suffix user-patterns

View File

@ -0,0 +1 @@
tessedit_char_whitelist 0123456789-.

View File

@ -0,0 +1,2 @@
tessedit_create_hocr 1
hocr_font_info 0

View File

@ -0,0 +1 @@
tessedit_create_lstmbox 1

View File

@ -0,0 +1 @@
tessedit_create_pdf 1

View File

@ -0,0 +1 @@
debug_file /dev/null

View File

@ -0,0 +1 @@
tessedit_create_tsv 1

View File

@ -0,0 +1,3 @@
# This config file should be used with other cofig files which creates renderers.
# usage example: tesseract eurotext.tif eurotext txt hocr pdf
tessedit_create_txt 1

View File

@ -0,0 +1,2 @@
tessedit_write_unlv 1
unlv_tilde_crunching T

View File

@ -0,0 +1 @@
tessedit_create_wordstrbox 1

Binary file not shown.

Binary file not shown.

BIN
Traindata/tessdata/pdf.ttf Normal file

Binary file not shown.

28
pom.xml Normal file
View File

@ -0,0 +1,28 @@
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>me.akito123321.macro</groupId>
<artifactId>macro</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/net.sourceforge.tess4j/tess4j -->
<dependency>
<groupId>net.sourceforge.tess4j</groupId>
<artifactId>tess4j</artifactId>
<version>5.11.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.java.dev.jna/jna -->
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>5.14.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.java.dev.jna/jna-platform -->
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId>
<version>5.14.0</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,49 @@
package macro;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.platform.win32.WinDef.HWND;
import com.sun.jna.platform.win32.WinDef.LPARAM;
import com.sun.jna.platform.win32.WinDef.LRESULT;
import com.sun.jna.platform.win32.WinDef.WPARAM;
import com.sun.jna.ptr.PointerByReference;
public class EnumerateWindows {
static class Psapi {
static {
Native.register("psapi");
}
public static native int GetModuleBaseNameW(Pointer hProcess, Pointer hmodule, char[] lpBaseName, int size);
}
static class Kernel32 {
static {
Native.register("kernel32");
}
public static int PROCESS_QUERY_INFORMATION = 0x0400;
public static int PROCESS_VM_READ = 0x0010;
public static native int GetLastError();
public static native Pointer OpenProcess(int dwDesiredAccess, boolean bInheritHandle, Pointer pointer);
}
static class User32DLL {
static {
Native.register("user32");
}
public static native int GetWindowThreadProcessId(HWND hWnd, PointerByReference pref);
public static native HWND GetForegroundWindow();
public static native int GetWindowTextW(HWND hWnd, char[] lpString, int nMaxCount);
// public static native List<DesktopWindow> GetAllWindows(boolean onlyVisibleWindows);
public static native LRESULT SendMessageA(HWND hWnd, int msg, WPARAM wParam, LPARAM lParam);
}
}

View File

@ -0,0 +1,70 @@
package macro;
//import static macro.EnumerateWindows.User32DLL.GetAllWindows;
import static macro.EnumerateWindows.User32DLL.SendMessageA;
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import com.sun.jna.platform.DesktopWindow;
import com.sun.jna.platform.WindowUtils;
import com.sun.jna.platform.win32.WinDef.LPARAM;
import com.sun.jna.platform.win32.WinDef.WPARAM;
import com.sun.jna.platform.win32.WinUser;
public class Input {
public static void press(char c, int timeInMs) {
Robot robot;
try {
robot = new Robot();
robot.keyPress(KeyEvent.getExtendedKeyCodeForChar(c));
robot.delay(timeInMs);
robot.keyRelease(KeyEvent.getExtendedKeyCodeForChar(c));
} catch (AWTException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void press(char c) {
Robot robot;
try {
robot = new Robot();
robot.keyPress(KeyEvent.getExtendedKeyCodeForChar(c));
robot.delay(100);
robot.keyRelease(KeyEvent.getExtendedKeyCodeForChar(c));
} catch (AWTException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void press(char c, int timeInMs, String windowName) {
DesktopWindow window = WindowUtils.getAllWindows(true).stream()
.filter(w -> w.getTitle().toLowerCase().contains(windowName.toLowerCase())).findFirst().get();
System.out.println(SendMessageA(window.getHWND(), WinUser.WM_KEYDOWN, new WPARAM(c), new LPARAM(0)));
try {
Thread.sleep(timeInMs);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
SendMessageA(window.getHWND(), WinUser.WM_KEYUP, new WPARAM(c), new LPARAM(0));
}
public static void press(char c, String windowName) {
DesktopWindow window = WindowUtils.getAllWindows(true).stream()
.filter(w -> w.getTitle().toLowerCase().contains(windowName.toLowerCase())).findFirst().get();
SendMessageA(window.getHWND(), WinUser.WM_KEYDOWN, new WPARAM(c), new LPARAM(0));
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
SendMessageA(window.getHWND(), WinUser.WM_KEYUP, new WPARAM(c), new LPARAM(0));
}
}

View File

@ -0,0 +1,92 @@
package macro;
import java.awt.Dimension;
import java.awt.MouseInfo;
import java.awt.Point;
import java.io.IOException;
import java.util.List;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.Timer;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
public class Main {
static JLabel label = new JLabel("sus");
static JFrame frame = new JFrame("Macro");
public static void main(String[] args) throws IOException, InterruptedException {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
new Thread(() -> {
// System.out.println(Text.getFromSquare(0, 0, 2560, 1440));
List<String> intrestedPokemon = List.of("Stunky", "Muk", "Smeargle", "Stantler", "Magikarp");
while (true) {
if (Window.isFocused("proclient")) {
// Input.press('a', 600);
// Input.press('d', 600);
String foundText = Text.getFromSquare(1200, 500, 1450, 540).trim();
if (!contains(intrestedPokemon, foundText) && foundText.toLowerCase().contains("wild")) {
Input.press('4');
// Input.press('1');
}else if(contains(intrestedPokemon, foundText)) {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Input.press('3');
Input.press('1');
}else {
Input.press('3');
}
System.out.println(foundText);
}
}
}).run();
}
private static void createAndShowGUI() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
| UnsupportedLookAndFeelException ex) {
ex.printStackTrace();
}
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent windowEvent) {
System.exit(0);
}
});
frame.getContentPane().add(label);
Timer timer = new Timer(100, e -> {
Point p = MouseInfo.getPointerInfo().getLocation();
label.setText(p.x + "/" + p.y);
});
timer.start();
// Display the window.
frame.setMinimumSize(new Dimension(500, 300));
frame.pack();
frame.setVisible(true);
}
private static boolean contains(List<String> pokemonWant, String pokemonFound) {
for (String s : pokemonWant) {
if (pokemonFound.toLowerCase().contains(s.toLowerCase()))
return true;
}
return false;
}
}

View File

@ -0,0 +1,32 @@
package macro;
import java.awt.AWTException;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;
public class Text {
public static String getFromSquare(int left, int top, int right, int bottom) {
BufferedImage bImage;
try {
Robot robot = new Robot();
Tesseract t = new Tesseract();
bImage = robot.createScreenCapture(new Rectangle(left, top,
Math.abs(left - right), Math.abs(top - bottom)));
// ImageIO.write(bImage, "PNG", new File("Images/test.png"));
t.setVariable("load_freq_dawg", "false");
t.setVariable("load_system_dawg", "false");
return t.doOCR(bImage);
} catch (AWTException | TesseractException e) {
e.printStackTrace();
return null;
}
}
}

View File

@ -0,0 +1,24 @@
package macro;
import static macro.EnumerateWindows.User32DLL.GetForegroundWindow;
import static macro.EnumerateWindows.User32DLL.GetWindowTextW;
import com.sun.jna.Native;
public class Window {
private static final int MAX_TITLE_LENGTH = 1024;
public static boolean isFocused(String windowName) {
return getFocusedWindow().toLowerCase().equals(windowName.toLowerCase());
}
public static boolean isFocusedNoFullName(String windowName) {
return getFocusedWindow().toLowerCase().contains(windowName.toLowerCase());
}
public static String getFocusedWindow() {
char[] buffer = new char[MAX_TITLE_LENGTH * 2];
GetWindowTextW(GetForegroundWindow(), buffer, MAX_TITLE_LENGTH);
return Native.toString(buffer).toLowerCase();
}
}

View File

@ -0,0 +1,11 @@
package ui;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
public class MoveMouseListener extends MouseAdapter {
@Override
public void mouseMoved(MouseEvent e) {
}
}

View File

@ -0,0 +1,4 @@
Manifest-Version: 1.0
Build-Jdk-Spec: 21
Created-By: Maven Integration for Eclipse

View File

@ -0,0 +1,7 @@
#Generated by Maven Integration for Eclipse
#Thu May 23 23:10:46 CEST 2024
artifactId=macro
groupId=me.akito123321.macro
m2e.projectLocation=C\:\\Users\\ronny\\eclipse-workspace\\macro
m2e.projectName=macro
version=0.0.1-SNAPSHOT

View File

@ -0,0 +1,28 @@
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>me.akito123321.macro</groupId>
<artifactId>macro</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/net.sourceforge.tess4j/tess4j -->
<dependency>
<groupId>net.sourceforge.tess4j</groupId>
<artifactId>tess4j</artifactId>
<version>5.11.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.java.dev.jna/jna -->
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>5.14.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.java.dev.jna/jna-platform -->
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId>
<version>5.14.0</version>
</dependency>
</dependencies>
</project>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.