first commit
This commit is contained in:
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Python-generated files
|
||||||
|
__pycache__/
|
||||||
|
*.py[oc]
|
||||||
|
build/
|
||||||
|
dist/
|
||||||
|
wheels/
|
||||||
|
*.egg-info
|
||||||
|
|
||||||
|
# Virtual environments
|
||||||
|
.venv
|
||||||
25
detector.py
Normal file
25
detector.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
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)
|
||||||
49
main.py
Normal file
49
main.py
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import pyautogui
|
||||||
|
import time
|
||||||
|
|
||||||
|
# ==========================
|
||||||
|
# CONFIG
|
||||||
|
# ==========================
|
||||||
|
|
||||||
|
P1 = (34, 1236)
|
||||||
|
COLOR_P1 = (191, 156, 233)
|
||||||
|
|
||||||
|
P2 = (25, 1281)
|
||||||
|
COLOR_P2 = (166, 227, 161)
|
||||||
|
|
||||||
|
|
||||||
|
INTERVALO = 3
|
||||||
|
TOLERANCIA = 0
|
||||||
|
|
||||||
|
# ==========================
|
||||||
|
# FUNCIONES
|
||||||
|
# ==========================
|
||||||
|
|
||||||
|
def coincide(a, b, tol=0):
|
||||||
|
return all(abs(x - y) <= tol for x, y in zip(a, b))
|
||||||
|
|
||||||
|
|
||||||
|
print("Detector iniciado... Ctrl+C para salir.")
|
||||||
|
|
||||||
|
while True:
|
||||||
|
c1 = pyautogui.pixel(*P1)
|
||||||
|
c2 = pyautogui.pixel(*P2)
|
||||||
|
|
||||||
|
print(f"P1: {c1} | P2: {c2}")
|
||||||
|
|
||||||
|
if coincide(c1, COLOR_P1, TOLERANCIA) and coincide(c2, COLOR_P2, TOLERANCIA):
|
||||||
|
print("Colores correctos → Click en P1 + Enter")
|
||||||
|
|
||||||
|
# Mover a P1
|
||||||
|
pyautogui.moveTo(*P1, duration=0.2)
|
||||||
|
|
||||||
|
# Click
|
||||||
|
pyautogui.click()
|
||||||
|
|
||||||
|
# Enter
|
||||||
|
pyautogui.press("enter")
|
||||||
|
|
||||||
|
# Cooldown
|
||||||
|
time.sleep(5)
|
||||||
|
|
||||||
|
time.sleep(INTERVALO)
|
||||||
Reference in New Issue
Block a user