currently ive taken up a small project of mine when i was bored but have come into a small problem i am struggling to solve, recently ive started to get back into pokemon and have really enjoyed my time with it. but after catching my first shiny( a rare pokemon with inverted colors) i wanted to catch more, but not sit at my computer endlessly going through encounters so i wanted to create a script to do that for me. as seen below
`
import java.awt.Color;
import java.awt.Robot;
import java.util.concurrent.TimeUnit;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class App {
public static void main(String[] args) throws Exception {
JFrame f = new JFrame();
String name=JOptionPane.showInputDialog(f,"Enter Name");
if (name.equals("go")){
Redo();
}
}
public static void Redo()throws Exception {
Robot robot = new Robot();
robot.delay(5000);
robot.keyPress(10);
robot.delay(3000);
robot.keyPress(10);
robot.delay(3000);
robot.keyPress(10);
robot.delay(3000);
robot.keyPress(10);
robot.delay(3000);
robot.keyPress(10);
robot.delay(3000);
robot.keyPress(10);
robot.delay(3000);
robot.keyPress(10);
robot.delay(3000);
robot.keyPress(10);
robot.delay(3000);
robot.keyPress(10);
check();
}
public static void check() throws Exception{
Robot robot2 = new Robot();
Color color2 = new Color(255,255,185);
Color color = robot2.getPixelColor(1080, 446);
if ( color.equals(color2)==true){
// System.out.println("shiny found!");
System.exit(0);
}
else{
robot2.keyPress(123);
// System.out.println("no shiny ");
Redo();
}
}
}
`
what supposed to happen:in the script above a dialogue box pops up where i have to type "go" at that point i manually click into the game window,at which point a robot clicks to go though the different menu's(just the enter key) until it gets to normal play state, then it enters a battle with a pokemon at that point my check() asks another robot to check the screen coordinates for a color( this color is the color of the shiny) if they are both the same color the program ends if not it restarts ( pokemon games reset upon clicking F12) and ive tested this in the normal IDE environment( where i put the color of the shiny in the right screen coordinate) and everything seemed to work
what actually happened: when i actually try the game itself the game only registers the enter button once or maybe my robot only clicks once? im not too sure at with point after 15 or so seconds the robot clicks f12 since it cant find the shiny. and the program repeats, i am using a Jar. not sure if that could be the problem?
so my question is: is there any reason my robot would stop pressing the buttons? or could it be the game not registering them?
Any help is appreciated!