diff options
-rw-r--r-- | bot.py | 20 |
1 files changed, 7 insertions, 13 deletions
@@ -2,7 +2,7 @@ import time | |||
2 | 2 | ||
3 | import mss | 3 | import mss |
4 | import pyautogui as pg | 4 | import pyautogui as pg |
5 | from keyboard import press_and_release | 5 | from keyboard import send |
6 | from numpy import array, uint8 | 6 | from numpy import array, uint8 |
7 | 7 | ||
8 | 8 | ||
@@ -25,15 +25,6 @@ def is_tree(c1): | |||
25 | return False | 25 | return False |
26 | 26 | ||
27 | 27 | ||
28 | def parse_screen(img, moves): | ||
29 | left = [img[x, posY[0]] for x in posX] | ||
30 | for i in range(6): | ||
31 | if is_tree(left[i]): | ||
32 | moves.append("right, right") | ||
33 | else: | ||
34 | moves.append("left, left") | ||
35 | |||
36 | |||
37 | with mss.mss() as sct: | 28 | with mss.mss() as sct: |
38 | screen = sct.monitors[1] | 29 | screen = sct.monitors[1] |
39 | screen["width"] = screen["width"] / 2.0 | 30 | screen["width"] = screen["width"] / 2.0 |
@@ -42,7 +33,10 @@ with mss.mss() as sct: | |||
42 | while True: | 33 | while True: |
43 | img = array(sct.grab(screen)) | 34 | img = array(sct.grab(screen)) |
44 | moves = list() | 35 | moves = list() |
45 | parse_screen(img, moves) | 36 | left = [img[x, posY[0]] for x in posX] |
46 | for m in moves: | 37 | for i in range(6): |
47 | press_and_release(m) | 38 | if is_tree(left[i]): |
39 | send("right, right", True, True) | ||
40 | else: | ||
41 | send("left, left", True, True) | ||
48 | time.sleep(0.145) | 42 | time.sleep(0.145) |