-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDexTool.py
217 lines (161 loc) · 4.74 KB
/
DexTool.py
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
import sys
import time
import pygetwindow as gw
import pyautogui
import pytesseract as tess
tess.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
from PIL import Image
window = gw.getWindowsWithTitle('BlueStacks')[0]
window.activate()
window.moveTo(0, 0)
# Window Defaults
win_off = 42
win_x = window.left + 1
win_y = window.top + win_off + 1
win_w = 540 + win_off
win_h = 800 + win_off
time.sleep(0.5)
# Functions?
def check(x, y, w, h, t, c):
px = win_x + x
py = win_y + y
while True:
print("Try: " + t+"\t", end =" ")
shot = pyautogui.screenshot(region=(px, py, w, h))
txt = tess.image_to_string(shot)
print("Read: " + txt)
if not c:
if txt == t:
return True
else:
return False
else:
if txt == t:
break
pyautogui.click(x=px + w / 2, y=py + h / 2)
return
def check_allpokemon(click=True):
return check(108, 100, 150, 48, "All Pokémon", click)
def check_labels(click=False):
return check(214, 74 - win_off, 60, 30, "Labels", click)
def check_exit(click=False): # Doesn't Work
return check(270, 814 - win_off, 36, 36, "X", click)
def check_box(tx_, click=False):
px = 124
py = 210 - win_off
pw = 150
ph = 64
drag = 96 + 24
bit = 4
while True:
found = check(px, py, pw, ph, tx_, click)
img = Image.open(r"C:\Users\green\AppData\Local\HOME Macros\img.png")
text = tess.image_to_string(img)
if found:
break
else:
pyautogui.moveTo(win_x + win_w / 2, win_y + win_h / 2)
pyautogui.mouseDown()
pyautogui.moveTo(win_x + win_w / 2, win_y + win_h / 2 - drag - bit, duration=0.25)
pyautogui.moveTo(win_x + win_w / 2, win_y + win_h / 2 - drag, duration=0.125)
pyautogui.mouseUp()
pyautogui.click(x=win_x + px + pw / 2, y=win_y + py + ph / 2)
return
def select_all():
# Drag Up Just In Case
st_x = win_x + 74
st_y = win_y + 340 - win_off
time.sleep(0.5)
pyautogui.moveTo(x=st_x, y=st_y)
pyautogui.mouseDown()
pyautogui.moveTo(x=st_x, y=st_y + 400, duration=0.5)
pyautogui.mouseUp()
st_x = win_x + 74
st_y = win_y + 340 - win_off
spc_x = 106
spc_y = 136
pyautogui.mouseDown(x=st_x, y=st_y)
time.sleep(3)
pyautogui.mouseUp()
j = 0
while j < 4:
i = 0
while i < 5:
if not (i == 0 and j == 0):
pyautogui.click(x=st_x + i * spc_x, y=st_y + j * spc_y)
time.sleep(0.125)
i += 1
j += 1
st_x = win_x + 76
st_y = win_y + 574 - win_off
pyautogui.moveTo(x=st_x, y=st_y)
pyautogui.mouseDown()
pyautogui.moveTo(x=st_x, y=st_y - 400, duration=0.25)
pyautogui.mouseUp()
j = 0
while j < 2:
i = 0
while i < 5:
pyautogui.click(x=st_x + i * spc_x, y=st_y + j * spc_y)
time.sleep(0.125)
i += 1
j += 1
click(64, 834, 0.5)
click(292, 555, 1.5)
click(292, 574, 8)
click(288, 834, 1)
click(288, 172, 0)
return
def click(x, y, sleep):
pyautogui.click(win_x + x, win_y + y - win_off)
time.sleep(sleep)
return
def wonder_loop(pus_x, pus_y, to, start_at, counter):
space = 104
i = 0
while i < to:
if counter >= start_at:
print("Opening Ball #"+str(counter+1)+".")
click(pus_x + i * space, pus_y, 18)
while True:
if pyautogui.pixelMatchesColor(win_x + 392, win_y + 628 - win_off, (247, 251, 247), tolerance=10):
break
else:
time.sleep(1)
click(276, 648, 1)
i += 1
counter += 1
return counter
def program_wonderopen():
if len(sys.argv) > 2:
if 0 < int(sys.argv[2]) <= 10:
start_at = int(sys.argv[2]) - 1
else:
print("ERROR: Start value needs to be between 1 and 10.")
sys.exit()
else:
start_at = 0
at = 0
at = wonder_loop(174, 288, 3, start_at, at)
at = wonder_loop(122, 458, 4, start_at, at)
at = wonder_loop(174, 624, 3, start_at, at)
print("Enjoy your Pokémon! :)")
return
# MAIN
if (len(sys.argv) > 1) and (sys.argv[1] == "-l"):
if not check_labels():
check_allpokemon()
box = "HOME"
count = 1
while count < 60:
tx = "{} {}".format(box, count)
check_box(tx)
time.sleep(0.5)
select_all()
count += 1
elif (len(sys.argv) > 1) and (sys.argv[1] == "-w"):
program_wonderopen()
else:
print("DexTool HOME v0.1 by @PoshoDev")
print("-l\tAuto label.")
print("-w\tOpen all completed Wonder trades.")