I am using ImageGrab from PIL to get the RGB value of specific pixels on my screen. I am having trouble understanding where I set the x and y coordinates for it get the pixels from. Here is mode code so far:
from PIL import ImageGrab
import threading
def getcol():
global pxcolor
threading.Timer(0.5, getcol).start()
pixel=ImageGrab.grab().load()
for y in range(0,1,1):
for x in range(0,1,1):
pxcolor=pixel[x,y]
print(pxcolor)
getcol()
I tried changing the range
values for x
and y
but this changed how it got printed out. I am a beginner and I am sorry for the stupid question but I have been at this for quite long and can't figure it out. Currently it just gets the pixel from the top left of my screen. I would like to capture the single middle pixel on my 1920x1080 screen.
Thanks.