3 Kasım 2013 Pazar

read pixel data continuously


from ctypes import windll
import time
import win32api
import win32gui
import threading



class gecoo(threading.Thread):
    def __init__(self):      
        threading.Thread.__init__(self)
        self.x=0
        self.y=0
    def get_coor(self):
        self.x, self.y = win32api.GetCursorPos()
        return self.x,self.y
     
   


class gecolo(threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)
        self.i_desktop_window_id = win32gui.GetDesktopWindow()
        self.i_desktop_window_dc = win32gui.GetWindowDC(self.i_desktop_window_id)
    def get_pixel_colour(self,i_x, i_y):       
        long_colour = win32gui.GetPixel(self.i_desktop_window_dc, i_x, i_y)
        i_colour = int(long_colour)
        return (i_colour & 0xff), ((i_colour >> 8) & 0xff), ((i_colour >> 16) & 0xff)


if __name__ == "__main__":
    fo=gecoo()
    fg=gecolo()
    while 1:
        print fg.get_pixel_colour(fo.get_coor()[0],fo.get_coor()[1])

Hiç yorum yok:

Yorum Gönder