I'm making a program that recognizes cards say for poker
this is the code i have so far:
Code java:
<
import java.awt.*;
import java.awt.event.*;
import java.awt.Robot;
import java.awt.AWTException;
import java.awt.Rectangle;
import java.awt.Color;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import java.awt.Point;
import java.lang.Object;
import java.awt.geom.Point2D;
import java.until.Arrays:
public class Poker
{
public int main(String[] args) throws Exception
{
Robot robot = new Robot();
Color color1 = new Color(24, 26, 25);
int[] Array;
Array = new int[5];
Array[0] = (new Color(24, 26, 25)).getRGB();
Array[1] = (new Color(28, 40, 36)).getRGB();
Array[2] = (new Color(93, 89, 79)).getRGB();
Array[3] = (new Color(49, 51, 46)).getRGB();
Array[4] = (new Color(17, 30, 25)).getRGB();
Rectangle rectangle = new Rectangle(0, 0, 1365, 770);
BufferedImage image = robot.createScreenCapture(rectangle);
for(int x = 0; x < rectangle.getWidth(); x++)
{
for (int y = 0; y < rectangle.getHeight(); y++)
{
int[] pixels = image.getRGB(0, 0, image.getWidth(), image.getHeight(), null, 0, image.getWidth());
{
for (int i = 0; i < pixels.length; i++)
{
if (Array.equals(search, Array.copyOfRange(pixels, i, i + search.length)))
{
if(image.getRGB(x, y) == color1.getRGB())
{
robot.mouseMove(x, y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.delay(10);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
}
break;
}
}
}
}
}
}
>
i am getting 4 errors
1 java:42 cannot find symbol pointing at the search
2 java:42 cannot find symbol pointing at the search
3 java:42 operator + cannot be applied to int,search.length
4 java:42 cannot find symbol pointing at the Array.copyOfRange
now what this program is supposed to do:
take a screenshot buffer it and search through it until it finds 5 pixels with the same RGB values as in the Array and then using that same screenshot find the first pixel and move the mouse to it.
PS. sorry bout the weird looking deal im coding in NotePad++ and i guess those lines that are wrapped around are too long for the post sorry again
Re: I'm making a program that recognizes cards say for poker
Paste the exact error messages here. And try to understand the error messages, you will be able to solve them on their own.
Re: I'm making a program that recognizes cards say for poker
the reason im posting is because i dont know how to solve them and i understand them but because i imported the whatchumacallit and all idk why im getting them
1. java:43 cannot find symbol
symbol : variable search
location: class Poker
if (Array.equals(search, Array.copyOfRange(pixels, i , i + search.length)))
^
2: same error pointing at the second search
^
3: operatior + cannot be applied to int,search. length
copyOfRange(pixels, i , i + search.length)))
^
4: cannot find symbol
symbol : method copyOfRange(int[].int,<nulltype>)
location: class int[]
if (Array.equals(search, Array.copyOfRang(pixels, i, i + search.length)))
^
Re: I'm making a program that recognizes cards say for poker
Quote:
if (Array.equals(search, Array.copyOfRange(pixels, i, i + search.length)))
What is search?
Re: I'm making a program that recognizes cards say for poker
Why are you using static methods of the Array class? Does it have the methods you are calling?
Re: I'm making a program that recognizes cards say for poker
no i guess it does not but i imported the untility.Arrays so i was under the impression i could use search and other tools without making methods around them?
Re: I'm making a program that recognizes cards say for poker
Array is not Arrays. Your code uses the Array class???
Re: I'm making a program that recognizes cards say for poker
Re: I'm making a program that recognizes cards say for poker
Does it work the way you want it to?