I'm on ubuntu and I want to check every 0.1sec the color of a specific pixel on my screen. How can I do that?
I know about PIL but this would need a full screenshot every 0.1sec just for one single pixel.
Then I found this method using ctypes.windll : Faster method of reading screen pixel in Python than PIL?
But this wont work because I'm not on Windows. Any other idea?
Edit: Solved thanks to b_c
from Xlib import display, X
from PIL import Image #PIL
def getColor(x,y):
W, H = 1, 1
dsp = display.Display()
root = dsp.screen().root
raw = root.get_image(x, y, W, H, X.ZPixmap, 0xffffffff)
image = Image.frombytes("RGB", (W, H), raw.data, "raw", "BGRX")
print image.getpixel((0, 0))
time.sleep(0.01)