Python – Color picking from given coordinates

color-pickerpythonwindows

What is the simplest way to pick up the RGB color code of the given coordinates? For simplicity let's assume that the screen resolution is 1024×768 and color depth/quality 32 bits. The coordinates are given relative to the upper left corner of the screen. I'd like to get some tips or examples how it can be done with Python.

Best Solution

The win32gui ActivePython documentation should be useful. I think you can construct something like:

import win32gui
GetPixel(GetDC(WindowFromPoint( (XPos,YPos) )), XPos , YPos )