0

I'm really really beginning/nooby in this and i'm trying to detect the color green on my screen and when it shows up click the mouse button. im also using sublime text 2 but I also have idle.

    import ImageGrab
    import time
    time.clock()
    image = ImageGrab.grab()
    for y in range(0, 100, 10):
        for x in range(0, 100, 10):
            color = image.getpixel((x, y))
    print(time.clock())

i tried this but it just gives me this "ModuleNotFoundError: No module named 'ImageGrab'" I have been scouring the internet for littarl hours and i just cant find any tutorials that help with installing pillow. this is ridiculously complicated and im about to give up

vithil
  • 1
  • 1
  • 2

1 Answers1

1

Instead of

import ImageGrab

use

from PIL import ImageGrab

You should have PIL already installed. PIL is the "Python Image Library" and can be downloaded from https://www.pythonware.com/products/pil/

Note that PIL is quite old and seems to be only available for Python 2.x (and even older). You could also use the Python package Pillow instead, which is a fork of PIL. This can be installed using pip install Pillow in (recent versions of) Python 2 as well as 3.

wovano
  • 4,543
  • 5
  • 22
  • 49