Hello all!
I am having a few issues with my code and after hours of endlessly searching Java help sites and Java forums, I decided to bring my issue to the table to receive some help specific to me, I am receiving the error 'Illegal start of expression' with the '{' underlined with red showing the error, I am relatively new to Java coding however I am not new to coding in general, your help in this matter is greatly appreciated all, the code is listed below and performs functions such as screenshotting, variable retrieving from the screenshots, mouse movement and clicking then finally the outputting of the variable stored.
package Mouseclickingprogram;
import java.awt.image.*;
import java.awt.*;
import java.io.*;
import java.util.*;
import javax.imageio.ImageIO;
import java.awt.Robot;
import java.awt.event.InputEvent;
public class mouseclicker {
public static final String path_two = "C:/Pictures/Javascreenshots/";
public static final String path = "C:/Pictures/Javascreenshots/";
public static final String[] testtoclick = {"one","two","three","four","five"};
public static final String[] clickamount = {"1","2","3","4","5"};
// Screen section dimensions
public static final int TOP = 59; // distance from top of screen to top of the trade screen
public static final int BOTTOM = 685; // distance from top of screen to bottom of the trade screen
public static final int LEFT = 16; // distance from left of screen to left of the trade screen
public static final int RIGHT = 861; // distance from the left of the screen to the right of the trade screen
// click amount box
public static final int BOX_WIDTH = 125;
public static final int BOX_HEIGHT = 16;
public void main(String[] args)
{
// takes and saves a screenshot of the entire screen
public static BufferedImage screenCapture(int click, int instance)
throws HeadlessException, AWTException, IOException {
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
BufferedImage image = new Robot().createScreenCapture(
new Rectangle(dim));
BufferedImage image2 = new BufferedImage(dim.width, dim.height, BufferedImage.TYPE_INT_ARGB);
image2.getGraphics().drawImage(image, 0, 0, null);
ImageIO.write(image2, "png", new File(path_two + "scr" + click + "_" + instance + ".png"));
image = ImageIO.read(new File(path_two + "scr" + click + "_" + instance + ".png"));
return image;
}
static int[][] clickSamples = new int[clickamount.length][BOX_WIDTH * BOX_HEIGHT * 4];
static int[] clickSample = new int[BOX_WIDTH * BOX_HEIGHT * 4];
//finds the click amount number to enter once click has been made
static int getClick(BufferedImage image, int x, int y) {
image.getRaster().getPixels(x, y, BOX_WIDTH, BOX_HEIGHT, clickSample);
for (int j = 0; j < clickamount.length; j++) {
if (Arrays.equals(clickSample, clickSamples[j])) {
return j;
}
}
return -1;
}
public static void mouseclick (String[] args) throws Exception{
Robot r = new Robot();
r.mouseMove(757,118);
//Clicks on the screen
r.mousePress( InputEvent.BUTTON1_MASK );
r.mouseRelease( InputEvent.BUTTON1_MASK );
//Inserts the number found from the screen shotsa
System.out.println(clickamount.length);
}
}
I do hope you can provide me with some help and hopefully a solution.
Regards
Inf.