Note that there are some explanatory texts on larger screens.

plurals
  1. POrespond to color events with java
    primarykey
    data
    text
    <p>I am building a java application to solve puzzles. The way i am coding it basically the program will take a screen shot, find a pixel in the screen shot, and move the mouse though the Robot function to that position on the desktop. I understand the theory behind taking a screen shot, storing it in an array, exploring the array until a stored pixel with the right color combo pops up, and moving mouse to that position on screen, however i cannot for the life of me get the code down. If anyone knows, or could knock together a sample code that takes a screen shot, stores it in an array (or and storage device i don't know if array is the best for this particular use) finds a pixel from that array moves mouse to pixel position and then clears array, I would be amazingly great-full because this is driving me nuts!</p> <p>so far i have:</p> <p>public static void main(String[] args) throws Exception{</p> <pre><code>Robot robot = new Robot(); { private static Rectangle rectangle = new Rectangle(0, 0, 1075, 700); { BufferedImage image = r.createScreenCapture(rectangle); search: for(int x = 0; x &lt; rectangle.getWidth(); x++) { for(int y = 0; y &lt; rectangle.getHeight(); y++) { if(image.getRGB(x, y) == Color.getRGB(195, 174, 196)) { Robot.mouseMove(x, y); break search; } } } } </code></pre> <p>}</p> <p>i am getting three errors:</p> <ol> <li><p>illegal start of expression, the indicator pointing at the get in code segment below</p> <p>private static Rectangle rectangle = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());</p></li> <li><p>illegal start of expression, the indicator pointing at the Size in code segment below</p> <p>private static Rectangle rectangle = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());</p></li> <li><p>; expected indicator pointing at Rectangle rectangle </p> <p>private static Rectangle rectangle = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload