import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.image.BufferedImage;
public final class test
{
private static Robot robot;
public static boolean clickStatus;
public static void leftClick (int R, int G, int B)
{
Color myColorToMatch = new Color (R, G, B);
BufferedImage image = robot.createScreenCapture (new Rectangle (Toolkit.getDefaultToolkit ().getScreenSize ()));
int w = image.getWidth (null);
int h = image.getHeight (null);
int[] rgbs = new int[w*h];
image.getRGB (0, 0, w, h, rgbs, 0, w);
for (int y=0; y<h; y++) {
for (int x=0; x<w; x++) {
if (new Color (image.getRGB (x, y)).equals (myColorToMatch))
robot.mouseMove(x, y);
robot.mousePress (InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
break;
}
break;
}
}
public static void main(String[] args)
{
try
{
robot = new Robot();
}
catch(Exception Error)
{
Error.printStackTrace();
}
// dImp: 130,40,32 - 160,99,57 - 217,135,79
// banker: 139, 130, 129
boolean botLoop = true;
boolean bankStatus;
while (botLoop == true)
{
robot.delay (1000);
leftClick (96,96,98);
}
}
}
但是有一个问题,我不知道如何解决它。机器人只会在鼠标所在的地方每秒不断地单击,而不是转到/单击所需的像素。有人可以帮我吗?我找不到错误