How could I save the values of displayMousePosition()
, something like
x, y, rgb = pyautogui.displayMousePosition()
How could I save the values of displayMousePosition()
, something like
x, y, rgb = pyautogui.displayMousePosition()
pyautogui.displayMousePosition()
monitors the position constantly of the mouse pointer and prints the position and RGB value of the pixel, so it is not a indicated method if you want to capture the values.
Instead you can combine pyautogui.position()
to get the coordinates and pyautogui.pixel()
for the RGB values of that pixel:
import pyautogui
while True:
x, y = pyautogui.position()
rgb = pyautogui.pixel(x, y)
# Haz lo que quieras con los valores x, y e rgb
print("x: {}, y: {}, RGB: {}".format(x, y, rgb))