Save values in pyautogui

0

How could I save the values of displayMousePosition() , something like

x, y, rgb = pyautogui.displayMousePosition()
    
asked by JackNavaRow 12.06.2018 в 08:11
source

1 answer

1

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))
    
answered by 12.06.2018 в 11:53