Created
November 18, 2019 04:36
-
-
Save owlscatcher/d3b81ef9004b76cfb25329abf63e2d53 to your computer and use it in GitHub Desktop.
Return HEX color code.
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
using System; | |
using System.Drawing; | |
using System.Windows.Forms; | |
class Program | |
{ | |
static Color GetPixel(Point position) | |
{ | |
using (var bitmap = new Bitmap(1, 1)) | |
{ | |
using (var graphics = Graphics.FromImage(bitmap)) | |
{ | |
graphics.CopyFromScreen(position, new Point(0, 0), new Size(1, 1)); | |
} | |
return bitmap.GetPixel(0, 0); | |
} | |
} | |
static void Main() | |
{ | |
Console.WriteLine(GetPixel(Cursor.Position)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment