这不是直接可能的,但是您可以
MouseInfo#getPointerInfo()用来获取指针当前所在的位置的信息。
int x = MouseInfo.getPointerInfo().getLocation().x;int y = MouseInfo.getPointerInfo().getLocation().y;
将屏幕截图作为后
BufferedImage,您可以在Java 2D API的帮助下将您自己的光标图像确切地放置在屏幕截图上的该位置。
Rectangle screen = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());BufferedImage screenCapture = new Robot().createScreenCapture(screen);Image cursor = ImageIO.read(new File("c:/cursor.gif"));int x = MouseInfo.getPointerInfo().getLocation().x;int y = MouseInfo.getPointerInfo().getLocation().y;Graphics2D graphics2D = screenCapture.createGraphics();graphics2D.drawImage(cursor, x, y, 16, 16, null); // cursor.gif is 16x16 size.ImageIO.write(screenCapture, "GIF", new File("c:/capture.gif"));


