Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <Windows.h>
  3.  
  4. int main(void) {
  5.     POINT p;
  6.     COLORREF color;
  7.     HDC hDC;
  8.     BOOL b;
  9.  
  10.     // Get the device context for the screen
  11.     hDC = GetDC(NULL);
  12.     if (hDC == NULL)
  13.         return 3;
  14.  
  15.     // Get the current cursor position
  16.     b = GetCursorPos(&p);
  17.     if (!b)
  18.         return 2;
  19.  
  20.     // Retrieve the color at that position
  21.     color = GetPixel(hDC, p.x, p.y);
  22.     if (color == CLR_INVALID)
  23.         return 1;
  24.  
  25.     // Release the device context again
  26.     ReleaseDC(GetDesktopWindow(), hDC);
  27.  
  28.     printf("%i %i %i", GetRValue(color), GetGValue(color), GetBValue(color));
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement