如何在屏幕上单击所需的像素?

How to Click a desired pixels on the screen?

我正在尝试制作一个点击屏幕上指定像素的程序。

我可以这样截屏

Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Rectangle screenRectangle = new Rectangle(screenSize);
Robot robot = new Robot();
BufferedImage image = robot.createScreenCapture(screenRectangle)

但我不知道如何在这张图片上做程序。

我可以用什么来做到这一点?谢谢:)

您可以使用 Robot class 在 java

中用鼠标点击特定像素
import java.awt.Robot;
import java.awt.AWTException;
import java.awt.event.InputEvent;

public class MouseClicker {

    static Robot rb;

    public static void main(String[] args) {

        try {
            rb = new Robot();
        } catch (AWTException e) {
            System.out.println("Error while creating object" + e);
        }


   rb.mouseMove(1360, 768); //this method takes two parameters (Height, Width)
   rb.mousePress(InputEvent.BUTTON1_DOWN_MASK);//this method takes one parameter (BUTTON) to press it
   rb.delay(10); //this is the delay between every press
   rb.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);//this method takes one parameter (BUTTON) to release it

    }

}

更多参考资料请看Oracle Docs