aboutsummaryrefslogtreecommitdiff
path: root/bot.py
diff options
context:
space:
mode:
Diffstat (limited to 'bot.py')
-rw-r--r--bot.py90
1 files changed, 90 insertions, 0 deletions
diff --git a/bot.py b/bot.py
new file mode 100644
index 0000000..5effc4b
--- /dev/null
+++ b/bot.py
@@ -0,0 +1,90 @@
1# from pyautogui import *
2import pyautogui
3from time import sleep
4
5
6def move(_pos, _now):
7 if _pos == 'left' and _now == 'left':
8 pyautogui.typewrite(['left'])
9 pyautogui.typewrite(['left'])
10 elif _pos == 'left' and _now == 'right':
11 pyautogui.typewrite(['right'])
12 pyautogui.typewrite(['right'])
13 elif _pos == 'right' and _now == 'right':
14 pyautogui.typewrite(['right'])
15 pyautogui.typewrite(['right'])
16 elif _pos == 'right' and _now == 'left':
17 pyautogui.typewrite(['left'])
18 pyautogui.typewrite(['left'])
19
20width, height = pyautogui.size()
21width *= 0.5
22pyautogui.moveTo(333, 600)
23pyautogui.click()
24
25posY = [360, 260, 160]
26posX = [276, 398]
27
28q = ['left', 'left', 'left']
29
30im = pyautogui.screenshot(region=(0, 0, width, height))
31l0 = im.getpixel((posX[0], posY[0]))
32l1 = im.getpixel((posX[0], posY[1]))
33l2 = im.getpixel((posX[0], posY[2]))
34
35r0 = im.getpixel((posX[1], posY[0]))
36r1 = im.getpixel((posX[1], posY[1]))
37r2 = im.getpixel((posX[1], posY[2]))
38
39if l0[0] == 161 and l0[1] == 116 and l0[2] == 56:
40 q[0] = 'right'
41 pos = 'right'
42else:
43 pos = 'left'
44if l1[0] == 161 and l1[1] == 116 and l1[2] == 56:
45 q[1] = 'right'
46if l2[0] == 161 and l2[1] == 116 and l2[2] == 56:
47 q[2] = 'right'
48
49qlen = 3
50
51while True:
52 if qlen == 3:
53 now = q[0]
54 move(pos, now)
55 now = q[1]
56 move(pos, now)
57 now = q[2]
58 move(pos, now)
59 qlen = 0
60 elif qlen == 0:
61 im = pyautogui.screenshot(region=(0, 0, width, height))
62 l0 = im.getpixel((posX[0], posY[0]))
63 l1 = im.getpixel((posX[0], posY[1]))
64 l2 = im.getpixel((posX[0], posY[2]))
65
66 r0 = im.getpixel((posX[1], posY[0]))
67 r1 = im.getpixel((posX[1], posY[1]))
68 r2 = im.getpixel((posX[1], posY[2]))
69
70 if l0[0] == 161 and l0[1] == 116 and l0[2] == 56:
71 q[0] = 'right'
72 else:
73 q[0] = 'left'
74 if l1[0] == 161 and l1[1] == 116 and l1[2] == 56:
75 q[1] = 'right'
76 else:
77 q[1] = 'left'
78 if l2[0] == 161 and l2[1] == 116 and l2[2] == 56:
79 q[2] = 'right'
80 else:
81 q[2] = 'left'
82
83 now = q[0]
84 move(pos, now)
85 now = q[1]
86 move(pos, now)
87 now = q[2]
88 move(pos, now)
89
90 sleep(0.095)
Powered by cgit v1.2.3 (git 2.41.0)