-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbarrows.py
More file actions
699 lines (593 loc) · 19.4 KB
/
Copy pathbarrows.py
File metadata and controls
699 lines (593 loc) · 19.4 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
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
import pyautogui
from pyautogui import keyDown, keyUp
import time
import win32gui
import pytesseract
import win32com.client
import sys
import random
pytesseract.pytesseract.tesseract_cmd = 'C:/Program Files/Tesseract-OCR/tesseract.exe'
# your path may be different
def find_window():
#Look through all your windows
def search(handle, window):
text = win32gui.GetWindowText(handle)
rect = win32gui.GetWindowRect(handle)
#Get coordinates
x = rect[0]
y = rect[1]
w = rect[2] - x
h = rect[3] - y
#If the window has Runelite, it saves the coordinates
if "runelite" in text.lower():
print(f"Window {win32gui.GetWindowText(handle)}:")
print(f"\tLocation: ({x},{y})")
print(f"\tSize: ({w},{h})")
window.append({'handle':handle,'x':x,'y':y,'w':w,'h':h})
#Store all windows that match and output found window, will be first in list (and only)
window = []
win32gui.EnumWindows(search, window)
return window[0]
#Get window dimensions
window = find_window()
print(window)
x,y,w,h = window['x'], window['y'], window['w'], window['h']
print(x,y,w,h)
#Set window into foreground
shell = win32com.client.Dispatch("WScript.Shell")
shell.SendKeys('%')
win32gui.SetForegroundWindow(window['handle'])
time.sleep(1)
def long_click(input_x,input_y,button="left"):
#Sometimes click happens too fast to register, manual for better responsiveness
pyautogui.moveTo(input_x,input_y)
pyautogui.mouseDown(button=button)
time.sleep(0.4)
pyautogui.mouseUp(button=button)
def healing():
while True:
# Healing
hp = pyautogui.pixelMatchesColor(hp_x, hp_y, (19, 19, 19))
if hp:
print('need hp')
monkfish = pyautogui.locateCenterOnScreen('monkfish.png', confidence=0.9)
if monkfish:
long_click(monkfish, None)
long_click(monkfish, None)
else:
break
else:
break
#Initialized PyAutoGui
pyautogui.FAILSAFE = True
# ---------- VARIABLES SECTION ----------
#Display tab coordinates
display_tab = x+574, y+256
#Brightness level coordinates
brightness = x+711, y+333
# Coordinates for Hitpoint healer
hp_x = x + 550
hp_y = y + 85
#Countdown timer
print("Starting", end="")
for i in range(0,3):
print(".", end="")
time.sleep(1)
print("Go")
# ---------- SETTING THE BASICS START ----------
#Click on compass
long_click(x+564, y+48)
#Move Mouse in center of window
pyautogui.moveTo(x+w/2, y+h/2)
#Move camera up
keyDown("up")
time.sleep(1.5)
keyUp("up")
# Click on setting tab
keyDown("F10")
time.sleep(0.5)
#Click on display setting
long_click(display_tab, None)
time.sleep(0.5)
#Set the brightness level
long_click(brightness, None)
time.sleep(0.5)
# click on inventory tab
keyDown("F1")
time.sleep(0.5)
#Move Mouse in center of window
pyautogui.moveTo(x+w/2, y+h/2)
time.sleep(0.2)
#Scroll up a lot
for i in range(10):
pyautogui.scroll(-550)
time.sleep(0.1)
#Scroll up a lot
for i in range(10):
pyautogui.scroll(250)
time.sleep(0.1)
# ---------- SETTING THE BASICS END ----------
# INITIAL LOOP
master_loop = 1
for i in range(200):
print("Master Loop", master_loop)
master_loop += 1
# Go home
pyautogui.write('::home')
time.sleep(0.2)
keyDown('enter')
time.sleep(0.5)
pyautogui.write('::home')
time.sleep(0.2)
keyDown('enter')
time.sleep(3)
# From home, go bank from minimap
long_click(x + 658, y + 83)
time.sleep(3.5)
# Open bank
long_click(x+ 321, y + 178)
time.sleep(0.5)
deposit = pyautogui.locateCenterOnScreen('deposit.png', confidence=0.9)
if deposit:
long_click(deposit, None)
time.sleep(0.5)
pyautogui.press('esc')
time.sleep(0.5)
# Click minimap reset pool
long_click(x + 625, y + 128)
time.sleep(3.5)
# Click on pool
long_click(x + 181, y + 212)
time.sleep(0.5)
# Click on quest tab
long_click(x + 616, y + 212)
time.sleep(0.5)
# Click on load out tab
long_click(x + 606, y + 242)
time.sleep(0.5)
# Click on barrows load out
barrows = pyautogui.locateCenterOnScreen('barrows.png', confidence=0.9)
if barrows:
long_click(barrows, None)
time.sleep(0.5)
pyautogui.press('F1')
time.sleep(0.5)
rune_bolt = pyautogui.locateOnScreen('rune_bolt.png', confidence=0.9)
if not rune_bolt:
print('Rune Bolt not found in inv')
sys.exit()
fire_rune = pyautogui.locateOnScreen('fire_rune.png', confidence=0.9)
if not fire_rune:
print('Fire Rune not found in inv')
sys.exit()
death_rune = pyautogui.locateOnScreen('death_rune.png', confidence=0.9)
if not death_rune:
print('Death Rune not found in inv')
sys.exit()
monkfish = pyautogui.locateOnScreen('monkfish.png', confidence=0.9)
if not monkfish:
print('Monkfish not found in inv')
sys.exit()
# Open mage tab
pyautogui.press('F3')
time.sleep(0.2)
# Click on teleport
long_click(x + 567, y + 247)
time.sleep(0.5)
# Click on minigames
minigames = pyautogui.locateCenterOnScreen('minigames.png', confidence=0.9)
if minigames:
long_click(minigames, None)
time.sleep(0.2)
barrows_tele = pyautogui.locateCenterOnScreen('barrows_tele.png', confidence=0.9)
if barrows_tele:
long_click(barrows_tele, None)
time.sleep(3)
# Open inv tab
pyautogui.press('F1')
time.sleep(0.5)
# Make sure magic is set
# Open combat tab
pyautogui.press('F5')
time.sleep(0.5)
# Click on spell
long_click(x + 687, y + 300) # remove 50 for spell
time.sleep(1)
iban = pyautogui.locateCenterOnScreen('iban_spell.png', confidence=0.9)
if iban:
long_click(iban, None)
time.sleep(0.5)
# Open inv tab
pyautogui.press('F1')
time.sleep(0.2)
# ---------- BARROWS START ----------
# ---------- VERAC ----------
print('Verac Started')
# Move to VERAC
long_click(x + 616, y + 152)
time.sleep(4)
# Click on spade
spade = pyautogui.locateCenterOnScreen('spade.png', confidence=0.9)
if spade:
long_click(spade, None)
time.sleep(2)
for i in range(10):
#Move Mouse in center of window
pyautogui.moveTo(x+w/2, y+h/2)
time.sleep(0.2)
# Right Click VERAC sarcophagus
long_click(x + 34, y + 188, button='right')
time.sleep(0.5)
search = pyautogui.locateCenterOnScreen('search_sarcophagus.png', confidence=0.9)
if search:
long_click(search, None)
time.sleep(0.5)
break
num = 1
# Heal during fight
for i in range(200):
time.sleep(0.2)
print('loop', num)
num += 1
healing()
nohp = pyautogui.locateOnScreen('0hp.png', region=(x+10, y+47, 135, 80))
if nohp:
print('0 HP Detected')
break
for i in range(10):
#Move Mouse in center of window
pyautogui.moveTo(x+w/2, y+h/2)
time.sleep(0.2)
# Climp up VERAC staircases
long_click(x + 422, y + 292, button='right')
time.sleep(0.2)
staircases = pyautogui.locateCenterOnScreen('staircases.png', confidence=0.9)
if staircases:
long_click(staircases, None)
time.sleep(5)
break
# ---------- DHAROK ----------
print('Dharok Started')
# Move to DHAROK
long_click(x + 717, y + 112)
time.sleep(6)
# Click on spade
spade = pyautogui.locateCenterOnScreen('spade.png', confidence=0.9)
if spade:
long_click(spade, None)
time.sleep(2)
# Activate Quick Prayers
long_click(x + 560, y + 118)
time.sleep(0.5)
for i in range(10):
#Move Mouse in center of window
pyautogui.moveTo(x+w/2, y+h/2)
time.sleep(0.2)
# Right Click DHAROK sarcophagus
long_click(x + 192, y + 352, button='right')
time.sleep(0.5)
search = pyautogui.locateCenterOnScreen('search_sarcophagus.png', confidence=0.9)
if search:
long_click(search, None)
time.sleep(0.5)
break
num = 1
# Heal during fight
for i in range(200):
time.sleep(0.2)
print('loop', num)
num += 1
healing()
nohp = pyautogui.locateOnScreen('0hp.png', region=(x+10, y+47, 135, 80))
if nohp:
print('0 HP Detected')
break
# Deactivate Quick Prayers
long_click(x + 560, y + 118)
time.sleep(0.5)
for i in range(10):
#Move Mouse in center of window
pyautogui.moveTo(x+w/2, y+h/2)
time.sleep(0.2)
# Climp up DHAROK staircases
long_click(x + 374, y + 110, button='right')
time.sleep(0.5)
staircases = pyautogui.locateCenterOnScreen('staircases.png', confidence=0.9)
if staircases:
long_click(staircases, None)
time.sleep(5)
break
# ---------- AHRIM ----------
print('Ahrim Started')
# Move to AHRIM
long_click(x + 615, y + 147)
time.sleep(6)
# Click on spade
spade = pyautogui.locateCenterOnScreen('spade.png', confidence=0.9)
if spade:
long_click(spade, None)
time.sleep(2)
#Move Mouse in center of window
pyautogui.moveTo(x+w/2, y+h/2)
time.sleep(0.2)
# Switch gear to range
rune_crossbow = pyautogui.locateCenterOnScreen('rune_crossbow.png', confidence=0.70)
if rune_crossbow:
long_click(rune_crossbow, None)
time.sleep(0.5)
else:
print('Rune Crossbow not found')
#Move Mouse in center of window
pyautogui.moveTo(x+w/2, y+h/2)
time.sleep(0.2)
# Switch gear to range
dragon_crossbow = pyautogui.locateCenterOnScreen('dragon.png', confidence=0.70)
if dragon_crossbow:
long_click(dragon_crossbow, None)
time.sleep(0.5)
else:
print('Dragon Crossbow not found')
#Move Mouse in center of window
pyautogui.moveTo(x+w/2, y+h/2)
time.sleep(0.2)
rune_bolt = pyautogui.locateCenterOnScreen('rune_bolt.png', confidence=0.8)
if rune_bolt:
long_click(rune_bolt, None)
time.sleep(0.5)
# Activate Mage Prayers
pyautogui.press('F2')
time.sleep(0.5)
# Click on anti mage
anti_mage = pyautogui.locateCenterOnScreen('anti_mage.png', confidence=0.9)
if anti_mage:
long_click(anti_mage, None)
time.sleep(0.5)
pyautogui.press('F1')
for i in range(10):
#Move Mouse in center of window
pyautogui.moveTo(x+w/2, y+h/2)
time.sleep(0.2)
# Right Click AHRIM sarcophagus
long_click(x + 192, y + 352, button='right')
time.sleep(0.5)
search = pyautogui.locateCenterOnScreen('search_sarcophagus.png', confidence=0.9)
if search:
long_click(search, None)
time.sleep(0.5)
break
num = 1
# Heal during fight
for i in range(200):
time.sleep(0.2)
print('loop', num)
num += 1
healing()
nohp = pyautogui.locateOnScreen('0hp.png', region=(x+10, y+47, 135, 80))
if nohp:
print('0 HP Detected')
break
# Deactivate Mage Prayers
pyautogui.press('F2')
time.sleep(0.5)
# Click on anti mage
anti_mage2 = pyautogui.locateCenterOnScreen('anti_mage2.png', confidence=0.9)
if anti_mage2:
long_click(anti_mage2, None)
time.sleep(0.5)
pyautogui.press('F1')
for i in range(10):
#Move Mouse in center of window
pyautogui.moveTo(x+w/2, y+h/2)
time.sleep(0.2)
# Climp up AHRIM staircases
long_click(x + 374, y + 110, button='right')
time.sleep(0.2)
staircases = pyautogui.locateCenterOnScreen('staircases.png', confidence=0.9)
if staircases:
long_click(staircases, None)
time.sleep(5)
break
iban_staff = pyautogui.locateCenterOnScreen('iban_staff.png', confidence=0.8)
if iban_staff:
long_click(iban_staff, None)
time.sleep(0.5)
#Move Mouse in center of window
pyautogui.moveTo(x+w/2, y+h/2)
time.sleep(0.2)
blessing = pyautogui.locateCenterOnScreen('blessing.png', confidence=0.8)
if blessing:
long_click(blessing, None)
time.sleep(0.5)
# ---------- TORAG ----------
print('Torag Started')
# Move to TORAG
long_click(x + 595, y + 134)
time.sleep(6)
# Click on spade
spade = pyautogui.locateCenterOnScreen('spade.png', confidence=0.9)
if spade:
long_click(spade, None)
time.sleep(2)
# Activate Quick Prayers
long_click(x + 560, y + 118)
time.sleep(0.5)
for i in range(10):
#Move Mouse in center of window
pyautogui.moveTo(x+w/2, y+h/2)
time.sleep(0.2)
# Right Click TORAG sarcophagus
long_click(x + 337, y + 52, button='right')
time.sleep(0.5)
search = pyautogui.locateCenterOnScreen('search_sarcophagus.png', confidence=0.9)
if search:
long_click(search, None)
time.sleep(0.5)
break
num = 1
# Heal during fight
for i in range(200):
time.sleep(0.2)
print('loop', num)
num += 1
healing()
nohp = pyautogui.locateOnScreen('0hp.png', region=(x+10, y+47, 135, 80))
if nohp:
print('0 HP Detected')
break
# Deactivate Quick Prayers
long_click(x + 560, y + 118)
time.sleep(0.5)
for i in range(10):
#Move Mouse in center of window
pyautogui.moveTo(x+w/2, y+h/2)
time.sleep(0.2)
# Climp up TORAG staircases
long_click(x + 112, y + 247, button='right')
time.sleep(0.2)
staircases = pyautogui.locateCenterOnScreen('staircases.png', confidence=0.9)
if staircases:
long_click(staircases, None)
time.sleep(4)
break
# ---------- KARIL ----------
print('Karil Started')
# Move to KARIL
long_click(x + 695, y + 137)
time.sleep(6)
# Click on spade
spade = pyautogui.locateCenterOnScreen('spade.png', confidence=0.9)
if spade:
long_click(spade, None)
time.sleep(2)
# Activate Range Prayers
pyautogui.press('F2')
time.sleep(0.5)
# Click on anti range
anti_range = pyautogui.locateCenterOnScreen('anti_range.png', confidence=0.9)
if anti_range:
long_click(anti_range, None)
time.sleep(0.5)
pyautogui.press('F1')
for i in range(10):
#Move Mouse in center of window
pyautogui.moveTo(x+w/2, y+h/2)
time.sleep(0.2)
# Right Click KARIL sarcophagus
long_click(x + 497, y + 232, button='right')
time.sleep(0.5)
search = pyautogui.locateCenterOnScreen('search_sarcophagus.png', confidence=0.9)
if search:
long_click(search, None)
time.sleep(0.5)
break
num = 1
# Heal during fight
for i in range(200):
time.sleep(0.2)
print('loop', num)
num += 1
healing()
nohp = pyautogui.locateOnScreen('0hp.png', region=(x+10, y+47, 135, 80))
if nohp:
print('0 HP Detected')
break
# Deactivate Range Prayers
pyautogui.press('F2')
time.sleep(0.5)
# Click on anti range
anti_range2 = pyautogui.locateCenterOnScreen('anti_range2.png', confidence=0.9)
if anti_range2:
long_click(anti_range2, None)
time.sleep(0.5)
pyautogui.press('F1')
for i in range(10):
#Move Mouse in center of window
pyautogui.moveTo(x+w/2, y+h/2)
time.sleep(0.2)
# Climp up KARIL staircases
long_click(x + 127, y + 102, button='right')
time.sleep(0.2)
staircases = pyautogui.locateCenterOnScreen('staircases.png', confidence=0.9)
if staircases:
long_click(staircases, None)
time.sleep(5)
break
# ---------- GUTHAN ----------
print('Guthan Started')
# Move to GUTHAN
long_click(x + 697, y + 92)
time.sleep(6)
# Click on spade
spade = pyautogui.locateCenterOnScreen('spade.png', confidence=0.9)
if spade:
long_click(spade, None)
time.sleep(2)
for i in range(10):
#Move Mouse in center of window
pyautogui.moveTo(x+w/2, y+h/2)
time.sleep(0.2)
# Right Click GUTHAN sarcophagus
long_click(x + 502, y + 209, button='right')
time.sleep(0.5)
search = pyautogui.locateCenterOnScreen('search_sarcophagus.png', confidence=0.9)
if search:
long_click(search, None)
time.sleep(3)
break
time.sleep(0.5)
#Move camera down
keyDown("down")
time.sleep(1.5)
keyUp("down")
time.sleep(0.5)
while True:
offset_x = random.randint(-5, 5)
offset_y = random.randint(-5, 5)
time.sleep(0.2)
# Click on chest
pyautogui.moveTo(x + 292 + offset_x, y + 48 + offset_y)
time.sleep(0.5)
pyautogui.click(button='right')
time.sleep(0.5)
chest = pyautogui.locateCenterOnScreen('chest.png', confidence=0.9)
if chest:
long_click(chest, None)
time.sleep(1)
break
# Activate Quick Prayers
long_click(x + 560, y + 118)
time.sleep(0.5)
#Move camera up
keyDown("up")
time.sleep(1.5)
keyUp("up")
num = 1
# Heal during fight
for i in range(200):
time.sleep(0.2)
print('loop', num)
num += 1
healing()
nohp = pyautogui.locateOnScreen('0hp.png', region=(x+10, y+47, 135, 80))
if nohp:
print('0 HP Detected')
break
# Deactivate Quick Prayers
long_click(x + 560, y + 118)
time.sleep(0.5)
while True:
offset_x = random.randint(-5, 5)
offset_y = random.randint(-5, 5)
time.sleep(0.2)
# Click on chest
pyautogui.moveTo(x + 287 + offset_x, y + 143 + offset_y)
open_chest = pyautogui.locateOnScreen('open_chest.png', confidence=0.8)
if open_chest:
pyautogui.click(button='right')
time.sleep(1)
chest = pyautogui.locateCenterOnScreen('chest.png', confidence=0.9)
if chest:
long_click(chest, None)
time.sleep(1)
break
time.sleep(3)