-1
import pyautogui

while True:
    mouse_position = pyautogui.position()
    print(mouse_position)
    if pyautogui.pixel(mouse_position)[0] == 255:
        pyautogui.mouseDown()
        pyautogui.mouseUp()
        print("Target detected!")
    else:
        print("Nothing detected!")`

I'm getting the mouse position (x, y) but when I put it in the parenthesis pyautogui.pixel(mouse_position) it gives me the error:

TypeError: pixel() missing 1 required positional argument: 'y'
Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
Carlos_s
  • 1
  • 1
  • 2

1 Answers1

0

Use pyautogui.pixel(*mouse_position) to unpack the tuple. Alternatively:

x, y = pyautogui.position()
pyautogui.pixel(x, y)
C.Nivs
  • 12,353
  • 2
  • 19
  • 44