Search code examples
pythonpython-imaging-librarypyautogui

pyautogui.displayMousePosition() doesn't work in pyautogui


enter code hereHello!

I tried get the RGB color of the mouse position (like showed in this video https://www.youtube.com/watch?v=TERKvqfySYI) with pyautogui.displayMousePosition(), but it dosent works. This is the code:

import pyautogui as p

import PIL

print(p.displayMousePosition())

this is the console:

...

pyscreeze.PyScreezeException: The Pillow package is required to use this function.

What I've done wrong? How I fix?


Solution

  • In your code a=p.locateOnScreen('a.png') will return None so replace your code with:

    import pyautogui as p
    a = p.locateOnScreen('a.png')
    while True:
        if a != None:
            p.click(a)