Skip to content

Instantly share code, notes, and snippets.

@mrexodia
Created August 28, 2024 17:35
Show Gist options
  • Save mrexodia/2e1f405b4b39c54c9b4329a79fddb00b to your computer and use it in GitHub Desktop.
Save mrexodia/2e1f405b4b39c54c9b4329a79fddb00b to your computer and use it in GitHub Desktop.
import time
import pyautogui
if __name__ == "__main__":
while True:
x, y = pyautogui.position()
h = 400
count = 0
print("testing...")
for i in range(h):
cy = y - int(h / 2) + i
try:
if pyautogui.pixelMatchesColor(x, cy, (255, 0, 0), 0):
count += 1
print("red pixel found", count)
if count == 10:
print("red bar detected")
pyautogui.leftClick(x, cy)
time.sleep(1.0)
pyautogui.moveTo(x, y)
break
except OSError:
pass
pyautogui.moveRel(1, 0)
time.sleep(1.0)
pyautogui.moveRel(-1, 0)
time.sleep(1.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment