26 lines
590 B
Python
26 lines
590 B
Python
import pyautogui
|
|
import keyboard
|
|
import time
|
|
|
|
print("Listo. Pulsa 'P' para imprimir posición y color. Ctrl+C para salir.")
|
|
|
|
def obtener_pixel_mouse():
|
|
# Posición actual del ratón
|
|
x, y = pyautogui.position()
|
|
|
|
# Captura solo 1x1 px (eficiente)
|
|
img = pyautogui.screenshot(region=(x, y, 1, 1))
|
|
color = img.getpixel((0, 0))
|
|
|
|
print(f"Posición: ({x}, {y}) | Color RGB: {color}")
|
|
|
|
|
|
while True:
|
|
if keyboard.is_pressed("p"):
|
|
obtener_pixel_mouse()
|
|
|
|
# Anti-rebote para no spamear mientras mantienes la tecla
|
|
time.sleep(0.3)
|
|
|
|
time.sleep(0.05)
|