I have some code that searches a predetermined area for a specific color. However, I want to take a screenshot of the area (done), search the entirety of it for the color (done), and if the color appears at all, do the search again for the same area. If the color is never found, exit the script. I can't seem to figure out where to put the if statements and brackets. What I have now doesn't quite work.
import java.awt.*;
import java.awt.image.BufferedImage;
public class Main {
public static void main(String[] args) throws AWTException {
boolean isFound = true;
while (isFound == true){
BufferedImage image = new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
BufferedImage image2 = new Robot().createScreenCapture(new Rectangle(70, 102,200,222));
isFound = false;
for (int y = 0; y < image2.getHeight(); y++) {
for (int x = 0; x < image2.getWidth(); x++) {
Color pixcolor = new Color(image2.getRGB(x, y));
int red = pixcolor.getRed();
int green = pixcolor.getGreen();
int blue = pixcolor.getBlue();
System.out.println("Red = " + red);
System.out.println("Green = " + green);
System.out.println("Blue = " + blue);
if (red == 255 & green == 255 & blue == 0){
isFound = true;
}
else{
isFound = false;
}
}
}
}
while (isFound == false){
System.exit(1);
}
}
}