76 lines
1.5 KiB
Python
76 lines
1.5 KiB
Python
from PIL import ImageGrab
|
||
import time
|
||
import os
|
||
# mouse = Controller()
|
||
from pynput.keyboard import Key, Controller
|
||
keyboard = Controller()
|
||
|
||
# x = [610, 620, 630, 640, 650, 660, 670, 680, 690,
|
||
# 700, 710, 720, 730, 740, 750, 760, 770, 780, 790,
|
||
# 800, 810, 820, 830, 840, 850, 860, 870, 880, 890]
|
||
# полоса по Х
|
||
|
||
x = [10, 20, 30, 40, 50, 60, 70, 80, 90,
|
||
100, 110, 120, 130, 140, 150, 160, 170, 180, 190,
|
||
200, 210, 220, 230, 240, 250, 260, 270, 280, 290]
|
||
# полоса по Х
|
||
|
||
def go(y):
|
||
|
||
global stop
|
||
print("Go with y =", y)
|
||
for i in range(len(x)):
|
||
|
||
try:
|
||
color = image.getpixel((x[i], y))
|
||
except:
|
||
pass
|
||
|
||
if color != (83, 83, 83) and i > 15:
|
||
|
||
print("\033[31mALERT", i, "\033[0m")
|
||
keyboard.press(Key.right)
|
||
time.sleep(0.1)
|
||
keyboard.release(Key.right)
|
||
print("\033[31mGo right!\033[0m")
|
||
|
||
|
||
stop = False
|
||
return stop
|
||
|
||
elif color != (83, 83, 83) and i < 15:
|
||
|
||
print("\033[31mDETECTED at", i, "\033[0m")
|
||
keyboard.press(Key.left)
|
||
time.sleep(0.1)
|
||
keyboard.release(Key.left)
|
||
print("\033[31mGo left!\033[0m")
|
||
|
||
stop = False
|
||
return stop
|
||
|
||
|
||
for i1 in range(99999999):
|
||
|
||
stop = True
|
||
|
||
image = ImageGrab.grab((597, 240, 895, 505))
|
||
print("screenshot №" + str(i1))
|
||
|
||
|
||
go(y=60)
|
||
|
||
if stop:
|
||
go(y=40)
|
||
|
||
if stop:
|
||
go(y=30)
|
||
|
||
if stop:
|
||
go(y=20)
|
||
|
||
if stop:
|
||
go(y=15)
|
||
|
||
#os.system("clear")
|