[python-win32] How to Get a pixel color?

Cyril.Liu terry6394 at gmail.com
Fri Nov 16 17:53:09 CET 2007


*Hello All,
I try to get a pixel color according to x,y pixel coordinates using this
code, but it doesn't work.*

>>> import win32ui
>>> w = win32ui.FindWindow(None, "11")
>>> dc = w.GetWindowDC()
>>> color = dc.GetPixel(100,100)
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
win32ui: GetPixel failed

*I can do it in VC++ like this:*

COLORREF GetColor(HWND hWnd, int x, int y)
{
    COLORREF color;
    HDC hDC = NULL;
    hDC = GetDC(hWnd);
    color = GetPixel(hDC, x, y);
    ReleaseDC(hWnd, hDC);
    return color;
}

*bye the way. Where is the** GetPixel(hDC, x, y) like win32SDK in pythonwin?
*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20071117/7ab9449e/attachment.htm 


More information about the python-win32 mailing list