-
Notifications
You must be signed in to change notification settings - Fork 0
/
RuneScape HotKeys.ahk
3020 lines (2154 loc) · 69.2 KB
/
RuneScape HotKeys.ahk
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
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#SingleInstance force
FGP_Init()
CoordMode, ToolTip, screen
CoordMode, Mouse, screen
CoordMode, Pixel, screen
global RS_WIN_1 := 0
initRSWindow()
global ERROR_LOG_FILE := "E:\Documents\2019\OSRS Icons\__ErrorLog.txt"
global globalClickID := 0
global saveCurrentID := 0
global saveMousePos_X := 0
global saveMousePos_Y := 0
global SCREEN_X1 := 0
global SCREEN_Y1 := 0
global SCREEN_X2 := 0
global SCREEN_Y2 := 0
global MINIMAP_X1 := 0
global MINIMAP_Y1 := 0
global MINIMAP_X2 := 0
global MINIMAP_Y2 := 0
;----------- screen 2 start ---------------
global SCREEN_X3 := 0
global SCREEN_Y3 := 0
global SCREEN_X4 := 0
global SCREEN_Y4 := 0
global MINIMAP_X3 := 0
global MINIMAP_Y3 := 0
global MINIMAP_X4 := 0
global MINIMAP_Y4 := 0
;------------ screen 2 end ----------------
global MM_CENTER_X_OFFSET := 90
global MM_CENTER_Y_OFFSET := 115
global MM_RADIUS := 74
findRSWindow()
global BACKPACK_X := 0
global BACKPACK_Y := 0
; still need to be initialized for some reason
; global variables initialized in command +^e
global GREEN := 0x005F00
global YELLOW := 0xD88020
global TAN_LOW := 0x900000
global SELLING_1 := 0x3D372E
global SELLING_2 := 0x3C352D
global EMPTY_SLOT_HIGH := 0x495000
global EMPTY_SLOT_LOW := 0x460000
global COLOR_ZAMORAK_WINE := 0xBD4C43
global NUM_AVAILABLE_SLOTS := 3
global ESCAPE_SEQUENCE := false ; false = continue with sequence
global CURRENT_LOOP := 0 ; parameter to track current pos in a loop
global TOTAL_LOOPS := 0
global TOGGLE_MONITOR_LOOPS := false
global TOGGLE_TELE_GRAB := false
global HIGH_ALCH_ITEM := ""
global HIGH_ALCH_NUM := 0
global HIGH_ALCH_PRICE := 0
global HIGH_ALCH_BUY_LIMIT := 0
global HIGH_VALUE := false
global BUY_COUNT := 0
global GLOBAL_TIME_OUT := 48
global PERSISTENCE_TOGGLE := false
global MY_PASSWORD := "my password"
;--------------------------------------------------------------------------------------------------------------------
; High Alch Items
;--------------------------------------------------------------------------------------------------------------------
global TITLE_MITHRIL_PICKAXE := "mithril pickaxe" ; x40 max num
global TITLE_MITHRIL_KITESHIELD := "mithril kiteshield" ; x125 max num
global TITLE_MITHRIL_2H_SWORD := "mithril 2h sword" ; x125 max num
global TITLE_MITHRIL_PLATEBODY := "mithril platebody" ; x125 max num
global VALUE_MITHRIL_PICKAXE := 536
global VALUE_MITHRIL_KITESHIELD := 1082
global VALUE_MITHRIL_2H_SWORD := 1316
global VALUE_MITHRIL_PLATEBODY := 2876
global TITLE_ADAMANT_SQ_SHIELD := "adamant sq" ; x125 max num
global TITLE_ADAMANT_KITESHIELD := "adamant kite" ; x125 max num
global TITLE_ADAMANT_2H_SWORD := "adamant 2h" ; x125 max num
global TITLE_ADAMANT_PLATEBODY := "adamant platebody" ; x125 max num
global VALUE_ADAMANT_SQ_SHIELD := 2060
global VALUE_ADAMANT_KITESHIELD := 3020
global VALUE_ADAMANT_2H_SWORD := 3596
global VALUE_ADAMANT_PLATEBODY := 9740
global TITLE_RUNE_MED_HELM := "rune med" ; x70 max num
global TITLE_RUNE_SCIMITAR := "rune scimitar" ; x70 max num
global TITLE_RUNE_FULL_HELM := "rune full" ; x70 max num
global TITLE_RUNE_SQ_SHIELD := "rune sq" ; x70 max num
global TITLE_RUNE_CHAINBODY := "rune chainbody" ; x70 max num
global TITLE_RUNE_KITESHIELD := "rune kite" ; x70 max num
global TITLE_RUNE_PLATELEGS := "rune platelegs" ; x70 max num
global TITLE_RUNE_PLATESKIRT := "rune plateskirt" ; x70 max num
global TITLE_RUNE_2H_SWORD := "rune 2h" ; x70 max num
global TITLE_RUNE_PLATEBODY := "rune platebody" ; x70 max num
global VALUE_RUNE_MED_HELM := 11200;
global VALUE_RUNE_SCIMITAR := 15060
global VALUE_RUNE_FULL_HELM := 20800
global VALUE_RUNE_SQ_SHIELD := 22700
global VALUE_RUNE_CHAINBODY := 29700
global VALUE_RUNE_KITESHIELD := 32300
global VALUE_RUNE_PLATELEGS := 38050
global VALUE_RUNE_PLATESKIRT := 38050
global VALUE_RUNE_2H_SWORD := 38100
global VALUE_RUNE_PLATEBODY := 38650
global TITLE_GREEN_DHIDE_BODY := "green d'hide body" ; x125 max num
global VALUE_GREEN_DHIDE_BODY := 4400
global TITLE_STEEL_PLATEBODY := "steel platebody" ; x125 max num
global VALUE_STEEL_PLATEBODY := 952
global TITLE_IRON_PLATEBODY := "iron platebody" ; x125 max num
global VALUE_IRON_PLATEBODY := 105
;--------------------------------------------------------------------------------------------------------------------
; ICONS
;--------------------------------------------------------------------------------------------------------------------
global Click_X := 0
global Click_Y := 0
;--------------------------------------------------------------------------------------------------------------------
; ICONS _ LOGIN
;--------------------------------------------------------------------------------------------------------------------
global LOGIN_EXISTING_USER := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0002s_0000_Login-Existing-User.png"
global LOGIN_CLICK_TO_SWITCH_WORLDS := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0002s_0002_Login-Click-to-switch-World.png"
global LOGIN_VERIFY_PASSWORD_IS_ENTERED := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0002s_0003_Login-Password-Entered.png"
global LOGIN_BUTTON := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0002s_0004_Login-Button.png"
global LOGIN_CLICK_HERE_TO_PLAY := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0002s_0006_Login-Click-Here-To-Play.png"
global LOGIN_MUSIC_ICON := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0002s_0001_Login-Music-On.png"
global LOGIN_LOGO := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0002s_0005_Login-Logo.png"
global LOGIN_SELECT_WORLD := "E:\Documents\2019\OSRS Icons\_World 379.png"
global COMPASS := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0005s_0000_Compass.png"
global ZOOM_ICON := "E:\Documents\2019\OSRS Icons\_Zoom Icon.png"
;--------------------------------------------------------------------------------------------------------------------
; ICONS _ GE
;--------------------------------------------------------------------------------------------------------------------
global GE_TITLE_ICON := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0000s_0003_GE-Title.png"
global GE_EMPTY_SLOT := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0000s_0000_Empty-GE-Box.png"
global GE_BLANK_SLOT := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0000s_0018_GE-BLANK-Box.png"
global GE_GREEN_SLOT := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0000s_0016_GE-COMPLETED-Box.png"
global GE_NOT_SOLD_SLOT := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0000s_0017_GE-INCOMPLETE-Box.png"
global GE_SELL_ICON := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0000s_0001_GE-Empty-Sell-Tab.png"
global GE_BUY_ICON := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0000s_0002_GE-Empty-Buy-Tab.png"
global GE_EXIT_BUTTON := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0000s_0006_GE-Close-Button.png"
global GE_ABORT_OFFER_BUTTON := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0000s_0008_GE-Abort-Offer-Icon.png"
global GE_COLLECT_BUTTON := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0000s_0007_GE-Collect-Icon.png"
global GE_EMPTY_RETURN_BOX := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0000s_0009_GE-Empty-Return-Icon.png"
global GE_OFFER_RETURN_BUTTON := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0000s_0015_GE-Offer-Return-Button.png"
global GE_CONFIRM := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0000s_0014_GE-Confirm-Offer-Button.png"
global GE_PRICE_SET_PAGE := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0000s_0010_GE-Price-to-pay.png"
global GE_PRICE_SET_BUTTON := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0000s_0013_GE-Set-Price-Button.png"
global GE_NUM_SET_PAGE := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0000s_0011_GE-How-many-to-buy.png"
global GE_NUM_SET_BUTTON := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0000s_0012_GE-Set-Quantity-Button.png"
global GE_WHAT_SET_PAGE := "E:\Documents\2019\OSRS Icons\_GE_what_to_buy_prompt.png"
;--------------------------------------------------------------------------------------------------------------------
; ICONS _ TABS
;--------------------------------------------------------------------------------------------------------------------
global TAB_COMBAT := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0001s_0006_Combat-Tab-Icon.png"
global TAB_BACKPACK := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0001s_0007_Backpack-Tab-Icon.png"
global TAB_EQUIPMENT := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0001s_0008_Equipment-Tab-Icon.png"
global TAB_PRAYER := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0001s_0009_Prayer-Tab-Icon.png"
global TAB_MAGIC := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0001s_0010_Magic-Tab-Icon.png"
global TAB_SETTINGS := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0001s_0011_Settings-Tab-Icon.png"
;--------------------------------------------------------------------------------------------------------------------
; ICONS _ BACKPACK
;--------------------------------------------------------------------------------------------------------------------
global FRAME_BACKPACK := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0003s_0000_Backpack.png"
global ITEM_NATURE_RUNE := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0003s_0001_Backpack-Nature-Rune.png"
;--------------------------------------------------------------------------------------------------------------------
; ICONS _ MAGIC
;--------------------------------------------------------------------------------------------------------------------
global SPELL_HIGH_ALCH := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0006s_0013_spell-high-alchemy.png"
;--------------------------------------------------------------------------------------------------------------------
; ICONS _ PROMPTS
;--------------------------------------------------------------------------------------------------------------------
global PROMPT_H_ALCH_1_WARNING := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0005s_0002_high-alchemy-prompt-1.png"
global PROMPT_H_ALCH_1_CONTINUE := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0005s_0001_paper-click-here-to-continue.png"
global PROMPT_H_ALCH_2_CONTINUE := "E:\Documents\2019\OSRS Icons\_High_alchemy_prompt_2_confirm.png"
global PROMPT_H_ALCH_2_CANCEL := "E:\Documents\2019\OSRS Icons\_High_alchemy_prompt_2_cancel.png"
global PROMPT_MINING_FULL := "E:\Documents\2019\OSRS Icons\_RS_PROMPT_MINING_FULL.png"
;--------------------------------------------------------------------------------------------------------------------
; ICONS _ CLICK
;--------------------------------------------------------------------------------------------------------------------
global CLICK_EMPTY := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0004s_0000_Right-Click-Empty.png"
global PLAYER_HEAD := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0005s_0005_Black-Square-(player-head).png"
global CLICK_EXAMINE := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0004s_0001_Examine-Click.png"
global CLICK_DROP := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0004s_0002_Drop-Click.png"
global CLICK_EXCHANGE := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0004s_0003_Exchange-Click.png"
;--------------------------------------------------------------------------------------------------------------------
; ICONS _ MINI MAP
;--------------------------------------------------------------------------------------------------------------------
global FRAME_MINI_MAP := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0008s_0000_minimap-border.png"
global MINI_MAP_TREE := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0008s_0002_minimap-tree.png"
global LOG_OUT_BUTTON := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0008s_0000_Logout-X.png"
global MINI_MAP_PLAYER := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0008s_0003_minimap-player-dot.png"
global EXIT_APP_BUTTON_BLUE := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0005s_0005_exit-app.png"
global EXIT_APP_BUTTON_WHITE := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0005s_0006_exit-app-button-white.png"
global WINDOW_MAXIMIZE_BLUE := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0005s_0005_Window-Maximize-button-blue.png"
global WINDOW_MAXIMIZE_WHITE := "E:\Documents\2019\OSRS Icons\OSRS-Icon-Search_0005s_0006_Window-Maximize-button-white.png"
;--------------------------------------------------------------------------------------------------------------------
; ICONS _ GLOBAL MAP
;--------------------------------------------------------------------------------------------------------------------
global G_MAP_PLAYER_LOC := "E:\Pictures\Screenshots\Screenshot (128).png"
;--------------------------------------------------------------------------------------------------------------------
; ICONS _ GLOBAL MAP
;--------------------------------------------------------------------------------------------------------------------
global SMELT_CLICK := "E:\Documents\2019\OSRS Icons\_RS_SMELT_RCLICK.png"
global SMELT_BRONZE_ICON := "E:\Documents\2019\OSRS Icons\_RS_SMELT_BRONZE_BUTTON.png"
global BANK_CLICK := "E:\Documents\2019\OSRS Icons\_RS_BANK_RCLICK.png"
global TIN_ORE_ICON := "E:\Documents\2019\OSRS Icons\_RS_COPPER_ORE_ICON.png"
global COPPER_ORE_ICON := "E:\Documents\2019\OSRS Icons\_RS_TIN_ORE_ICON.png"
;-------- smelt gold amulet run -----------------------------
global GOLD_BAR_ICON := "E:\Documents\2019\OSRS Icons\_RS_GOLD_BAR_ICON.png"
global SMELT_GOLD_AMULET_ICON := "E:\Documents\2019\OSRS Icons\_RS_SMELT_GOLD_AMULET_ICON.png"
; global MAKE_ALL_GOLD_AMULET_CLICK := "E:\Pictures\Screenshots\Screenshot (149).png"
global MAKE_ALL_GOLD_AMULET_CLICK := "E:\Pictures\Screenshots\Screenshot (149).png"
;------------ superheat item --------------------------------------
global ICON_IRON_ORE := "E:\Documents\2019\OSRS Icons\_RS_IRON_ORE_ICON.png"
global ICON_COAL := "E:\Documents\2019\OSRS Icons\_RS_COAL_ICON.png"
global ICON_SUPERHEAT_ITEM := "E:\Documents\2019\OSRS Icons\_RS_SUPERHEAT_ICON.png"
;------------ telegrab -------------------------------------------
global SPELL_TELE_GRAB := "E:\Documents\2019\OSRS Icons\_RS_SPELL_TELE_GRAB.png"
global SPELL_TELE_GRAB_2 := "E:\Documents\2019\OSRS Icons\_RS_SPELL_TELE_GRAB_2.png"
global ITEM_ZAMORAK_WINE_JUG := "E:\Documents\2019\OSRS Icons\_RS_WIINE_JUG.png"
;--------------------------------------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------------------------------------
sendToRS(text) {
IfWinExist, Old School RuneScape
WinActivate
Else
return ExitFunction(false)
waitForLiftKey_AndBlockInput()
Loop, 20
{
send, {BackSpace}
}
send, %text%
return ExitFunction(true)
}
initRSWindow() {
WinGet, RS_WIN_1, ID, A
;msgbox, % "rs win: " . RS_WIN_1
}
findRSWindow() {
if WinExist("ahk_id " . RS_WIN_1) {
WinGetPos, SCREEN_X1, SCREEN_Y1, w, h, ahk_id %RS_WIN_1%
SCREEN_X2 := SCREEN_X1 + w
SCREEN_Y2 := SCREEN_Y1 + h
return ExitFunction(true)
}
else {
Log_Flag("********** Old School RuneScape Window Is not Open! **********")
DEBUG("Old School RuneScape Window Is not Open!")
return ExitFunction(false)
}
}
Re_InitializeParameters()
{
initRSWindow()
CoordMode, ToolTip, screen
CoordMode, Mouse, screen
CoordMode, Pixel, screen
ERROR_LOG_FILE := "E:\Documents\2019\OSRS Icons\__ErrorLog.txt"
globalClickID := 0
saveCurrentID := 0
saveMousePos_X := 0
saveMousePos_Y := 0
SCREEN_X1 := 0
SCREEN_Y1 := 0
SCREEN_X2 := 0
SCREEN_Y2 := 0
BACKPACK_X := 0
BACKPACK_Y := 0
; global variables re - initialized in command +^e
GREEN := 0x005F00
YELLOW := 0xD88020
TAN_LOW := 0x900000
SELLING_1 := 0x3D372E
SELLING_2 := 0x3C352D
EMPTY_SLOT_HIGH := 0x495000
EMPTY_SLOT_LOW := 0x460000
NUM_AVAILABLE_SLOTS := 3
ESCAPE_SEQUENCE := false ; false = continue with sequence
CURRENT_LOOP := 0 ; parameter to track current pos in a loop
TOTAL_LOOPS := 0
TOGGLE_MONITOR_LOOPS := false
HIGH_ALCH_ITEM := ""
HIGH_ALCH_NUM := 0
HIGH_ALCH_PRICE := 0
HIGH_ALCH_BUY_LIMIT := 0
HIGH_VALUE := false
BUY_COUNT := 0
GLOBAL_TIME_OUT := 48
PERSISTENCE_TOGGLE := false
findRSWindow()
;MouseGetPos, xpos, ypos, globalClickID, control
;WinGetTitle, title, ahk_id %globalClickID%
;WinGetClass, class, ahk_id %globalClickID%
;MsgBox, %xpos% %ypos%`nahk_id %globalClickID%`nahk_class %class%`n%title%`nControl: %control%
}
reloadScript(){
BlockInput Off
MsgBox, reloading this script
flag_SUCCESS("reloading Script", 2)
Reload, E:\Documents\RuneScape HotKeys.ahk
}
+^r::
reloadScript()
Return
:*:r()::
reloadScript()
Return
+^p::
if (PERSISTENCE_TOGGLE = false){
PERSISTENCE_TOGGLE := true
#Persistent
CoordMode Pixel, Screen
CoordMode Mouse, Screen
SetTimer, WatchCursorColor, 100
} else {
PERSISTENCE_TOGGLE := true
SetTimer, WatchCursorColor, Off
tooltip ; disable tooltip
}
Return
WatchCursorColor:
MouseGetPos X, Y
PixelGetColor Color, %X%, %Y%, RGB
ToolTip, %X% %Y% - %Color%
Return
+^o::
tooltip ; disable tooltip
Return
+^w::
MsgBox, gcId %globalClickID%
Return
; initialize global variables
+^e::
MsgBox, re-initializing global variables
Re_InitializeParameters()
Return
+^q::
if (PERSISTENCE_TOGGLE = false){
PERSISTENCE_TOGGLE := true
; This example allows you to move the mouse around to see
; the title of the window currently under the cursor:
#Persistent
SetTimer, WatchCursor, 100
} else {
PERSISTENCE_TOGGLE := false
SetTimer, WatchCursor, Off
tooltip ; disable tooltip
}
Return
WatchCursor:
WinGetPos, x, y, w, h, Old School RuneScape
ToolTip, %x% %y% | %w% %h% | %WinTitle%
Return
waitForLiftKey_AndBlockInput() {
KeyWait Control
KeyWait Shift
KeyWait Alt
KeyWait Del
KeyWait BackSpace
BlockInput On
}
Log_Flag(text){
FormatTime, TimeString
text := "`n" . text . " --- " . TimeString
FileAppend, %text%, %ERROR_LOG_FILE%
}
resetErrorLog(){
FileDelete, %ERROR_LOG_FILE%
FileAppend, RuneScape AHK Error Log:`n, %ERROR_LOG_FILE%
}
sendNotification(text, duration := 2) {
TrayTip, OSRS AHK ERROR, %text%, %duration%
}
flag_error(text, duration := 2){
TrayTip, OSRS AHK ERROR, %text%, %duration%
Log_Flag(text)
}
flag_SUCCESS(text, duration) {
;TrayTip, OSRS AHK NOTIFY, %text%, %duration%
Log_Flag(text)
}
saveCurrentPosition()
{
MouseGetPos, saveMousePos_X, saveMousePos_Y, saveCurrentID
; DEBUG(saveMousePos_X . " " . saveMousePos_Y)
; DEBUG_MOUSE_POS(saveMousePos_X, saveMousePos_Y)
}
returnToLastSavedPosition()
{
winactivate, ahk_id %saveCurrentID%
MouseMove, %saveMousePos_X%, %saveMousePos_Y%
}
writeToNotepad(text) {
winactivate, Untitled - Notepad
WinWaitActive, Untitled - Notepad
send, %text%
}
+^a::
MouseGetPos, OVX, OVY
writeToNotepad("{tab}{tab}RSClick(" . OVX . ", " . OVY . ", 100){enter}")
Return
+^c::
MouseGetPos, OVX, OVY
writeToNotepad("{tab}{tab}RSInputClick(" . OVX . ", " . OVY . ", 1000, EnterTextHere , 500)")
Return
+^x::
MouseGetPos, OVX, OVY
writeToNotepad("{tab}{tab}RSRightClick(" . OVX . ", " . OVY . ", 100){enter}")
Return
sendClick(x, y, mouse){
if (mouse = left) {
RSClick(x, y, 0)
}
else if (mouse = right) {
RSRightClick(x, y, 0)
}
else {
flag_error("sendClick() : mouse param error: " . mouse, 2)
return ExitFunction(false)
}
return ExitFunction(true)
}
RSClick(rsX, rsY, sleeperTime)
{
; send click and input to RS
Send {Click, %rsX%, %rsY%}
sleep, %sleeperTime%
}
RSClick_X(rsX, rsY, sleeperTime)
{
waitForLiftKey_AndBlockInput()
RSClick(rsX, rsY, sleeperTime)
resetClickPos()
return ExitFunction(true)
}
RSInputClick(rsX := 0, rsY := 0, sleeperTime_One := 0, input := "", sleeperTime_Two := 0)
{
; send click and input to RS
if (rsX != 0) {
send {Click, %rsX%, %rsY%}
}
sleep, %sleeperTime_One%
send, %input%
sleep, 1000
send, {enter}
sleep, %sleeperTime_Two%
}
RSRightClick(rsX, rsY, sleeperTime)
{
; send right click to RS
Send {Click, %rsX%, %rsY%, right}
sleep, %sleeperTime%
}
RSRightClick_X(rsX, rsY, sleeperTime) {
waitForLiftKey_AndBlockInput()
RSRightClick(rsX, rsY, sleeperTime)
resetClickPos()
return ExitFunction(true)
}
RSKeyHold(input_down, input_up, sleeperTime){
waitForLiftKey_AndBlockInput()
send %input_down%
sleep, sleeperTime
send, %input_up%
return ExitFunction(true)
}
RSSendInput(input){
waitForLiftKey_AndBlockInput()
winActivate, ahk_id %RS_WIN_1%
send, %input%
return ExitFunction(true)
}
ExitFunction(value){
BlockInput Off
return value
}
;------------------------------------------------------------------------------------------------------------------
;------------------------------------------------------------------------------------------------------------------
;------------------------------------------------------------------------------------------------------------------
clickIcon(image, maxWait := 1000, extra := "") {
var := false
if (extra = "silent") {
if !waitFor_Icon_Silent(image, maxWait) {
findRSWindow()
var := waitFor_Icon_Silent(image, maxWait)
} else {
var := true
}
} else {
if !waitFor_Icon_Silent(image, maxWait) {
findRSWindow()
var := waitFor_Icon_Verbose(image, maxWait)
} else {
var := true
}
}
if (var = false) {
if (ErrorLevel = 1){
Log_Flag(image . " was not found! ")
}
else if (ErrorLevel = 2) {
Log_Flag("was not able to search for image: " . image)
}
else {
Log_Flag("unknown error occured. ErrorLevel: " . ErrorLevel)
}
return ExitFunction(false)
}
if (extra = "right") {
RSRightClick_X(Click_X, Click_Y, 0)
}
else {
RSClick_X(Click_X, Click_Y, 0)
}
return ExitFunction(true)
}
openGE() {
Log_Flag("DEBUG: initiating openGE()")
timeOut := 5
counter := 1
if !searchScreen(GE_TITLE_ICON) {
RSClickOnPlayerHead("right")
if !clickIcon(CLICK_EXCHANGE, 200) {
mousemove, %SCREEN_X2%, %SCREEN_Y2%
}
}
while !waitFor_Icon_Silent(GE_TITLE_ICON, 600) {
RSClickOnPlayerHead("right")
if !clickIcon(CLICK_EXCHANGE, 200) {
mousemove, %SCREEN_X2%, %SCREEN_Y2%
}
if (counter = timeOut) {
Log_Flag("---- ERROR: openGE() Time Out")
return ExitFunction(false)
}
counter += 1
}
Log_Flag("*** EXIT_SUCCESS: exiting openGE() : SUCCESS")
return ExitFunction(true)
}
RSGetCenterScreen() {
findRSWindow()
w := SCREEN_X2 - SCREEN_X1
h := SCREEN_Y2 - SCREEN_Y1
Click_X := ( w / 2 ) + SCREEN_X1
Click_Y := ( h / 2 ) + SCREEN_Y1
}
RSFindPlayerHead(){
step := 100
h := SCREEN_Y2 - SCREEN_Y1
add := h / step
Click_Y -= add ; move up 1 step from center
}
RSClickOnPlayerHead(mouse := "left"){
Log_Flag("DEBUG: initiating RSClickOnPlayerHead(" . mouse . ")")
RSGetCenterScreen()
RSFindPlayerHead()
if (mouse = "right") {
return ExitFunction(RSRightClick_X(Click_X, Click_Y, 0))
} else {
return ExitFunction(RSClick_X(Click_X, Click_Y, 0))
}
Log_Flag("*** EXIT_SUCCESS: exiting RSClickOnPlayerHead() : SUCCESS")
}
RSEnterInTextBox(input, image){
if !waitFor_Icon_Verbose(image, 2000){
return ExitFunction(false)
}
RSInputClick(Click_X, Click_Y, 500, input, 300) ; click paper to enter text
return ExitFunction(true)
}
openBackpack(){
Log_Flag("DEBUG: initiating openBackpack()")
while !waitFor_Icon_Silent(FRAME_BACKPACK, 50) {
Log_Flag("DEBUG: FRAME_BACKPACK not found")
if !clickIcon(TAB_BACKPACK, 100){
Log_Flag("openBackpack() : Critical failure, reloading script")
reloadScript()
}
}
if (BACKPACK_X = 0) {
searchScreen_TopLeft(FRAME_BACKPACK)
BACKPACK_X := Click_X
BACKPACK_Y := Click_Y
}
Log_Flag("*** EXIT_SUCCESS: exiting openBackpack() SUCCESS")
return ExitFunction(true)
}
dropInventoryItem(row, col) {
Log_Flag("DEBUG: initiating clickInventoryItem()")
openBackpack()
shift_x := ( getWidth(FRAME_BACKPACK) / 5 ) * col
shift_y := ( getHeight(FRAME_BACKPACK) / 7.8 ) * row
x := BACKPACK_X + shift_x
y := BACKPACK_Y + shift_y
waitForLiftKey_AndBlockInput()
winActivate, %RS_WIN_1%
Send, {Shift Down}
RSClick(x, y, 0)
Send, {Shift UP}
return ExitFunction(true)
}
clickInventoryItem(row, col, mouse := "left") {
Log_Flag("DEBUG: initiating clickInventoryItem()")
openBackpack()
shift_x := ( getWidth(FRAME_BACKPACK) / 5 ) * col
shift_y := ( getHeight(FRAME_BACKPACK) / 7.8 ) * row
x := BACKPACK_X + shift_x
y := BACKPACK_Y + shift_y
if (mouse = "left"){
RSClick_X(x, y, 0)
}
else if (mouse = "right") {
RSRightClick_X(x, y, 0)
}
else {
flag_error("clickInventoryItem() : Invalid mouse parameter", 2)
return ExitFunction(false)
}
return ExitFunction(true)
}
waitForSlot_ToFill(slot, sleeperTime := 2500, timeOut := 5000) {
Log_Flag("DEBUG: initiating waitFor_Icon_Silent() : " . image)
if (sleeperTime > timeOut){
sleeperTime := timeOut / 3
}
timeOut := timeOut / sleeperTime
counter := 0
x1 := 1
y1 := 1
while checkInventorySlot_Empty(x1, y1) {
Log_Flag("WAIT: waitFor_Icon_Silent() - image not found: " . image)
if (ErrorLevel = 2) {
Log_Flag("---- ERROR: waitFor_Icon_Silent() - UNABLE TO SEARCH: ErrorLevel: " . ErrorLevel " - image: " . image)
return ExitFunction(false)
}
if (counter >= timeOut or ESCAPE_SEQUENCE = true) {
ESCAPE_SEQUENCE := false
Log_Flag("WAIT: waitFor_Icon_Silent() - Time Out : " . image)
return ExitFunction(false)
}
counter := counter + 1
if (timeOut != 0) {
sleep, %sleeperTime%
}
}
Log_Flag("*** EXIT_SUCCESS: exiting waitFor_Icon_Silent() : SUCCESS : " . image)
return ExitFunction(true)
}
checkInventorySlot(row, col, image){
waitForLiftKey_AndBlockInput()
Log_Flag("DEBUG: initiating checkInventorySlot()")
clickInventoryItem(row, col, "right")
waitForLiftKey_AndBlockInput()
sleep, 10
var := searchScreen(image, BACKPACK_X, BACKPACK_Y)
RSClick(Click_X, Click_Y, 0)
if (var = true) {
Log_Flag("*** EXIT_SUCCESS: exiting checkInventorySlot() : " . var)
} else {
Log_Flag("*** EXIT_FAILURE: exiting checkInventorySlot() : " . var)
}
return ExitFunction(var)
}
checkInventorySlot_Empty(row, col) {
Log_Flag("DEBUG: initiating checkInventorySlot_Empty()")
var := checkInventorySlot(row, col, CLICK_EMPTY)
if (var = true){
Log_Flag("DEBUG: Inventory Slot is Empty: " . row . " " . col)
} else {
Log_Flag("DEBUG: Inventory Slot - Item Found: " . row . " " . col)
}
if (var = true) {
Log_Flag("*** EXIT_SUCCESS: exiting checkInventorySlot_Empty() : " . var)
} else {
Log_Flag("*** EXIT_FAILURE: exiting checkInventorySlot_Empty() : " . var)
}
return ExitFunction(var)
}
examineInventorySlot(row, col) {
clickInventoryItem(row, col, "right")
clickIcon(CLICK_EXAMINE)
}
confirmNatureRune(){
openBackpack()
if waitFor_Icon_Silent(ITEM_NATURE_RUNE, 500) {
Log_Flag("DEBUG: Nature Rune Found!")
return ExitFunction(true)
} else {
Log_Flag("DEBUG: Nature Rune Not Found...")
return ExitFunction(false)
}
}
getImageValue(image, value){
w := FGP_Value(image, FGP_Num(value))
NewVar := RegExReplace(w, "\D")
return NewVar
}
getWidth(image){
return getImageValue(image, "Width")
}
getHeight(image){
return getImageValue(image, "Height")
}
searchScreen_TopLeft(image, x1 := -1, y1 := -1, x2 := -1, y2 := -1) {
if (x1 = -1){
x1 := SCREEN_X1
}
if (y1 = -1){
y1 := SCREEN_Y1
}
if (x2 = -1){
x2 := SCREEN_X2 + 100
}
if (y2 = -1){
y2 := SCREEN_Y2 + 100
}
ImageSearch, Click_X, Click_Y, x1, y1,x2,y2, *20 *TransBlack %image%
if (ErrorLevel = 0){
return ExitFunction(true)
} else {
return ExitFunction(false)
}
}