Last active
December 22, 2017 12:14
-
-
Save win0err/d6293b5cd62d5fcbecd587680c0eaca0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.Color; | |
import java.awt.Robot; | |
import java.awt.AWTException; | |
import java.awt.MouseInfo; | |
import java.awt.Point; | |
public class ColorPicker { | |
public static void main(String[] args) { | |
System.out.println("Press Ctrl+C to exit"); | |
while(true) { | |
try { | |
Robot robot = new Robot(); | |
Point p = MouseInfo.getPointerInfo().getLocation(); | |
Color color = robot.getPixelColor(p.x, p.y); | |
System.out.print( | |
"Color: " + color.getRed() + " " | |
+ color.getGreen() + " " | |
+ color.getBlue() | |
+ " \r"); | |
} catch (AWTException e) { | |
System.out.println("Can't run at headless environment"); | |
break; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment