-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
135 lines (122 loc) · 4.25 KB
/
Copy pathmain.py
File metadata and controls
135 lines (122 loc) · 4.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import pyautogui
from time import sleep
import getprocess
import pynput.keyboard as keyboard
#Variables declaration
images = ["Image/Stage_startb2.png","Image/Mission_startb.png","Image/Stage_finish.png", "Image/pause_button.png", "Image/levelup.png"]
stage_started = False
mission_started = False
missioncount = 0
correct_windows = True
afkbot = True
def resetvalue():
global stage_started, mission_started, missioncount, afkbot
stage_started = False
mission_started = False
correct_windows = True
afkbot = True
def botstop():
global afkbot
afkbot = False
def on_press(key):
global afkbot
if key == keyboard.Key.end:
afkbot = False
if key == keyboard.Key.home:
afkbot = True
sleep(.1)
def initlistener():
handler = keyboard.Listener(on_press=on_press)
handler.start()
def main():
global stage_started, mission_started, missioncount
count = 0
print("\rChecking for %s" %images[0])
while stage_started == 0 and afkbot:
try:
clickx, clicky = pyautogui.locateCenterOnScreen(images[0], confidence = 0.9)
except TypeError:
#print("\r%s not found. Retrying..." %images[1])
print(".")
clickpos = pyautogui.locateCenterOnScreen(images[2], confidence = 0.6)
if clickpos != None:
pyautogui.click(clickpos)
else:
print("Image found. Stage started")
pyautogui.click(clickx, clicky)
stage_started = True
print("\rChecking for %s" %images[1])
while stage_started and mission_started == 0 and afkbot:
try:
clickx, clicky = pyautogui.locateCenterOnScreen(images[1], confidence = 0.9)
except TypeError:
#print("\r%s not found. Retrying..." %images[1])
print(".")
clickpos = pyautogui.locateCenterOnScreen(images[0], confidence = 0.9)
if clickpos != None:
pyautogui.click(clickpos)
else:
print("Image found. Mission started")
pyautogui.click(clickx, clicky)
mission_started = True
print("Checking for result screen")
while stage_started and mission_started and afkbot:
try:
clickx, clicky = pyautogui.locateCenterOnScreen(images[2], confidence = 0.5)
sleep(2)
except TypeError:
print(".")
levelup = pyautogui.locateCenterOnScreen(images[4], confidence = 0.9)
if levelup != None:
pyautogui.click(levelup)
else:
pyautogui.click(clickx,clicky)
missioncount+=1
stage_started = False
mission_started = False
print("Stage completed. Restarting loop")
print("Mission Finished:", missioncount)
def main2():
global stage_started, mission_started, missioncount
count = 0
print("\rChecking for %s" %images[0])
clickpos = pyautogui.locateCenterOnScreen(images[0], confidence = 0.9)
sleep(1)
if clickpos != None:
print("Image found. Stage started")
pyautogui.click(clickpos)
else:
print("\rChecking for %s" %images[1])
clickpos = pyautogui.locateCenterOnScreen(images[1], confidence = 0.9)
sleep(1)
if clickpos != None:
print("Image found. Mission started")
pyautogui.click(clickpos)
else:
print("Checking for result screen")
clickpos = pyautogui.locateCenterOnScreen(images[2], confidence = 0.6)
sleep(1)
if clickpos != None:
pyautogui.click(clickpos)
print("Stage completed. Restarting loop")
print("Mission Finished:", missioncount)
else:
pass
if __name__ == "__main__":
initlistener()
while True:
while afkbot and correct_windows:
main()
# for i in images:
# try:
# print("Checking for %s" %i)
# clickx, clicky = pyautogui.locateCenterOnScreen(i)
# except TypeError:
# print("checking for the next image")
# else:
# print("Image found")
# pyautogui.click(clickx, clicky)
# if count == 5:
# pyautogui.click(1700,300)
# count+=1
# pyautogui.sleep(.5)