-
Notifications
You must be signed in to change notification settings - Fork 0
/
PoE-Enchantress.ahk
774 lines (668 loc) · 24.9 KB
/
PoE-Enchantress.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
; PoE-Enchantress a pricing tool for things which cannot be copied
; Copyright (C) 2021 LawTotem#8511
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <https://www.gnu.org/licenses/>.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance Force
SetBatchLines -1
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
global version := "0.4.0"
global show_update := false
global PID := DllCall("Kernel32\GetCurrentProcessId")
EnvGet, dir, USERPROFILE
global RoamingDir := dir . "\AppData\Roaming\POE-Enchantress"
if (!FileExist(RoamingDir)) {
FileCreateDir, %RoamingDir%
}
global SettingsPath := RoamingDir . "\settings.ini"
global TempPath := RoamingDir . "\temp.txt"
global RawTextCapture := ""
global RawCaptureTime := ""
tooltip, Loading Enchantress [Initializing Settings]
IniRead, FirstRun, %SettingsPath%, General, FirstRun
while (FirstRun == "ERROR" or FirstRun == "") {
IniWrite, 1, %SettingsPath%, General, FirstRun
sleep, 250
IniRead, FirstRun, %SettingsPath%, General, FirstRun
}
IniRead, GuiKey, %SettingsPath%, General, GuiKey
while (GuiKey == "ERROR" or GuiKey == "") {
IniWrite, ^+y, %SettingsPath%, General, GuiKey
sleep, 250
IniRead, GuiKey, %SettingsPath%, General, GuiKey
}
hotkey, %GuiKey%, OpenGui
IniRead, sc, %SettingsPath%, Other, scale
if (sc == "ERROR") {
iniWrite, 1, %SettingsPath%, Other, scale
}
IniRead tempMon, %SettingsPath%, Other, monitor
if (tempMon == "ERROR") {
iniWrite, 1, %SettingsPath%, Other, monitor
}
IniRead, EnchantScanKey, %SettingsPath%, General, EnchantScanKey
while (EnchantScanKey == "ERROR" or EnchantScanKey == "") {
IniWrite, ^y, %SettingsPath%, General, EnchantScanKey
sleep, 250
IniRead, EnchantScanKey, %SettingsPath%, General, EnchantScanKey
}
hotkey, %EnchantScanKey%, ScanEnchant
IniRead, HeistScanKey, %SettingsPath%, General, HeistScanKey
while (HeistScanKey == "ERROR" or HeistScanKey == "") {
IniWrite, ^u, %SettingsPath%, General, HeistScanKey
sleep, 250
IniRead, HeistScanKey, %SettingsPath%, General, HeistScanKey
}
hotkey, %HeistScanKey%, ScanHeist
IniRead, GeneralEnchantTxt, %SettingsPath%, User, GeneralEnchantTxt
while (GeneralEnchantTxt == "ERROR") {
IniWrite, "general_enchants.txt", %SettingsPath%, User, GeneralEnchantTxt
sleep, 250
IniRead, GeneralEnchantTxt, %SettingsPath%, User, GeneralEnchantTxt
}
IniRead, ServiceEnchantTxt, %SettingsPath%, User, ServiceEnchantTxt
while (ServiceEnchantTxt == "ERROR") {
IniWrite, "services.txt", %SettingsPath%, User, ServiceEnchantTxt
sleep, 250
IniRead, ServiceEnchantTxt, %SettingsPath%, User, ServiceEnchantTxt
}
IniRead, HeistPriceTxt, %SettingsPath%, User, HeistPriceTxt
while (HeistPriceTxt == "ERROR") {
IniWrite, "heists.txt", %SettingsPath%, User, HeistPriceTxt
sleep, 250
IniRead, HeistPriceTxt, %SettingsPath% User, HeistPriceTxt
}
IniRead, SnapshotScreen, %SettingsPath%, User, SnapshotScreen
while (SnapshotScreen == "ERROR") {
IniWrite, 0, %SettingsPath%, User, SnapshotScreen
sleep, 250
IniRead, SnapshotScreen, %SettingsPath%, User, SnapshotScreen
}
IniRead, HeistRemappingTxt, %SettingsPath%, User, HeistRemappingTxt
while (HeistRemappingTxt == "ERROR") {
IniWrite, "heist_remapping.txt", %SettingsPath%, User, HeistRemappingTxt
sleep, 250
IniRead, HeistRemappingTxt, %SettingsPath%, User, HeistRemappingTxt
}
IniRead, EnchantRemappingTxt, %SettingsPath%, User, EnchantRemappingTxt
while (EnchantRemappingTxt == "ERROR") {
IniWrite, "enchant_remapping.txt", %SettingsPath%, User, EnchantRemappingTxt
sleep, 250
IniRead, EnchantRemappingTxt, %SettingsPath%, User, EnchantRemappingTxt
}
IniRead, SaveEnchant, %SettingsPath%, User, SaveEnchant
while (SaveEnchant == "ERROR") {
IniWrite, 0, %SettingsPath%, User, SaveEnchant
sleep, 250
IniRead, SaveEnchant, %SettingsPath%, User, SaveEnchant
}
tooltip, Loading Enchantress [Enchant List]
tooltip, Loading Enchantress [Personal Lists]
if (FileExist("resources\ScalesOfJustice.png"))
{
menu, Tray, Icon, resources\ScalesOfJustice.png
}
Menu, Tray, NoStandard
Menu, Tray, Add, Enchantress, OpenGui
Menu, Tray, Default, Enchantress
Menu, Tray, Standard
tooltip, Loading [Building GUI]
sleep, 250
newGUI()
tooltip, Ready
sleep, 250
Tooltip
global last_version_grab := 0
global last_heist_grab := 0
global last_enchant_grab := 0
if (FirstRun == 1) {
goto help
}
if (checkUpdate())
{
global show_update := true
MsgBox A new version of the tool is available, check https://github.com/LawTotem/PoE-Enchantress/releases
}
Return
Return
OpenGui:
Gui, EnchantressUI:Show, w650 h585
Return
ScanEnchant:
_wasVisible := IsGuiVisible("EnchantressUI")
if (grabScreen("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`'+`%.")) {
Gui, EnchantressUI:Show, w650 h585
IniRead, EnchantRemappingTxt, %SettingsPath%, User, EnchantRemappingTxt
if (FileExist(EnchantRemappingTxt))
{
RemapScan(EnchantRemappingTxt)
}
enchantSort()
} else {
if (_wasVisible) {
Gui, EnchantressUI:Show, w650 h585
}
}
Return
ScanHeist:
_wasVisible := IsGuiVisible("EnchantressUI")
if (grabScreen("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`'-")) {
IniRead, HeistRemappingTxt, %SettingsPath%, User, HeistRemappingTxt
if (FileExist(HeistRemappingTxt))
{
RemapScan(HeistRemappingTxt)
}
GUI, EnchantressUI:Show, w650 h585
heistSort()
} else {
if (_wasVisible) {
Gui, EnchantressUI:Show, w650 h585
}
}
Return
RemapScan(filename) {
GuiControlGet, CaptureString,, CaptureS, value
new_capture := ""
FileRead, RemappingFile, %filename%
loop, parse, RemappingFile, `n, `r
{
remapLine := % A_LoopField
remaparray := StrSplit(remapLine, ":")
if (InStr(cleanString(CaptureString), cleanString(remaparray[1]), false))
{
if new_capture
{
new_capture := new_capture "`n"
}
new_capture := new_capture remaparray[2]
}
}
if new_capture
{
GuiControl,, CaptureS, %new_capture%
}
}
EntrantressUIGuiEscape:
EnchantressUIGuiClose:
Gui, EnchantressUI:Hide
Return
newGUI() {
global
Gui, EnchantressUI:New,, PoE-Enchantress v%version%
Gui, Color, 0x192020, 0x251e16
Gui, Font, s11 ce7b477
; === TITLE, ICON ===
if (FileExist("resources\ScalesOfJustice.png"))
{
Gui add, picture, x5 y5 w50 h50 gHelp , resources\ScalesOfJustice.png
}
Gui, add, text, x65 y20 w100 vversiontext, PoE-Enchantress v%version%
Gui, add, picture, x520 y10 w120 h40 gSettings, resources\settings.png
Gui, add, text, x10 y60 vValue, Captured String
Gui, add, edit, x10 y80 vCaptureS r5 w600
Gui, add, picture, x10 y180 gReprossEnchant, resources\enchant.png
Gui, add, picture, x240 y180 gDumpRaw, resources\dumpraw.png
Gui, add, picture, x490 y180 gReprossHeist, resources\heist.png
loop, 15 {
rowo := 210+20*A_Index
gui, add, text, x5 y%rowo%, _
gui, add, text, x10 y%rowo% w500 venchant_%A_Index%,
}
Gui, font
}
help:
Gui Help:new,, PoE-Enchantress Help
Gui, font, s14
Gui, add, text, x5 y5, Setup
Gui, add, text, x5 y75, Heist Prices
Gui, add, text, x5 y165, Enchant Prices
Gui, add, text, x5 y255, Usage
Gui, add, text, x5 y375, Credits`/License
Gui, font
IniRead, ServiceEnchantTxt, %SettingsPath%, User, ServiceEnchantTxt
IniRead, GeneralEnchantTxt, %SettingsPath%, User, GeneralEnchantTxt
IniRead, HeistPriceTxt, %SettingsPath%, User, HeistPriceTxt
Gui, font, s10
Gui, add, text, x15 y30, PoE-Enchantress uses the tool 'Capture2Text' to translate enchant/item names to text. This tool must be downloaded`r`nseperately and is available at http://capture2text.sourceforge.net/. Once downloaded the 'Capture2Text' folder should be moved`r`ninto the folder containing the PoE-Enchantress autohotkey script.
Gui, add, text, x15 y100, PoE-Enchantress does not use any external sites/tools to perform Heist item pricing. It uses a comma separated file 'heists.txt'`r`nwhich should be formatted as 'item name', 'price/comment'. The item name will be matched without capitalization and without spaces`r`n(because Capture2Text messes them up quite frequently). Original author uses a python script to download and parse`r`nskill gem and item overviews from 'poe.ninja'.
Gui, add, text, x15 y190, Just like for the Heist item pricing, we use comma separated files to help with enchant pricing. The format is`r`n'enchant subtext', 'comment to show'. Make the enchant subtext as minimal as possible, the longer it the greater the chance`r`nthe enchantment will be missed because it was miss parsed. Two files are used 'services.txt' is checked first, it is intended for`r`nany lab services you are running, and 'general_enchants.txt' is checked second, it is intended for base item enchanting.
Gui, add, text, x15 y280, Use either of the scan hotkeys to capture a region of the screen containing only the name of the item or list of enchants you want`r`nto price. After you press the hotkey you will be able to select a region by pressing and holding the left mouse key.`r`nYou may edit the captured text and click either of the reprocess texts, there is no feedback but it does reprocess.`r`nDefault hotkeys to open the UI = Ctrl + Shift + Y`r`nHotkey to Capture Enchants = Ctrl + Y`r`nHotkey to Capture Heist = Ctrl + U
Gui, add, text, x15 y400, This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License`r`nas published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.`r`n`r`nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty`r`nof MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.`r`n`r`nYou should have received a copy of the GNU General Public License along with this program.`r`nIf not, see <https://www.gnu.org/licenses/>.`r`nCopyright (C) 2021 LawTotem#8511
Gui, Help:Show, w800 h610
if (checkFiles())
{
IniWrite, 0, %SettingsPath%, General, FirstRun
}
Return
HelpGuiClose:
Gui, Help:Destroy
; Gui, EnchantressUI:Destroy
Return
ReprossEnchant:
IniRead, EnchantRemappingTxt, %SettingsPath%, User, EnchantRemappingTxt
if (FileExist(EnchantRemappingTxt))
{
RemapScan(EnchantRemappingTxt)
}
enchantSort()
Return
ReprossHeist:
IniRead, HeistRemappingTxt, %SettingsPath%, User, HeistRemappingTxt
if (FileExist(HeistRemappingTxt))
{
RemapScan(HeistRemappingTxt)
}
heistSort()
Return
DumpRaw:
GuiControl,, CaptureS, %RawTextCapture%
Return
Settings:
Gui Settings:new,, PoE-Enchantress Settings
Gui, font, s14
Gui, add, text, x5 y5, General Settings
Gui, font
offset = 5
Gui, font, s14
Gui, add, text, x5 y%offset%, General Settings
offset := offset + 25
Gui, font
Gui, font, s10
offset := addOption("General", "FirstRun", offset, "Show First Run Help")
offset := addOption("General", "GuiKey", offset, "Key Sequence to show GUI")
offset := addOption("General", "EnchantScanKey", offset, "Grab Enchant Key Sequence")
offset := addOption("General", "HeistScanKey", offset, "Grab Heist Item Key Sequence")
Gui, font
Gui, font, s14
Gui, add, text, x5 y%offset%, User Settings
offset := offset + 25
Gui, font
Gui, font, s10
offset := addOption("User", "HeistPriceTxt", offset, "Heist Price File")
offset := addOption("User", "ServiceEnchantTxt", offset, "Service Enchant File")
offset := addOption("User", "GeneralEnchantTxt", offset, "General Enchant File")
offset := addOption("User", "HeistRemappingTxt", offset, "Heist Text Remapping File")
offset := addOption("User", "EnchantRemappingTxt", offset, "Enchant Text Remapping File")
offset := addOption("User", "SnapshotScreen", offset, "Save a snapshot when OCRing screen")
offset := addOption("User", "SaveEnchant", offset, "Save Text Capture of Enchants")
Gui, font
Gui, font, s14
Gui, add, text, x5 y%offset%, Other Settings
offset := offset + 25
Gui, font
Gui, font, s10
offset := addOption("Other", "scale", offset, "Monitor Scale")
offset := addOption("Other", "monitor", offset, "Select Monitor")
Gui, font
Gui, font, s20
Gui, add, text, x350 y550 gSaveSettings, Save
Gui, Settings:Show, w800 h610
Return
SaveSettings:
offset := 0
saveOption("General", "FirstRun", offset, "Show First Run Help")
saveOption("General", "GuiKey", offset, "Key Sequence to show GUI")
saveOption("General", "EnchantScanKey", offset, "Grab Enchant Key Sequence")
saveOption("General", "HeistScanKey", offset, "Grab Heist Item Key Sequence")
saveOption("User", "HeistPriceTxt", offset, "Heist Price File")
saveOption("User", "ServiceEnchantTxt", offset, "Service Enchant File")
saveOption("User", "GeneralEnchantTxt", offset, "General Enchant File")
saveOption("User", "HeistRemappingTxt", offset, "Heist Text Remapping File")
saveOption("User", "EnchantRemappingTxt", offset, "Enchant Text Remapping File")
saveOption("User", "SnapshotScreen", offset, "Save a snapshot when OCRing screen")
saveOption("User", "SaveEnchant", offset, "Save Text Capture of Enchants")
saveOption("Other", "scale", offset, "Monitor Scale")
saveOption("Other", "monitor", offset, "Select Monitor")
Gui, Settings:Destroy
Return
SettingsGuiClose:
Gui, Settings:Destroy
Return
getHeistPrices(heist_price_txt)
{
if (SubStr(heist_price_txt,1,4) = "http")
{
global last_heist_grab
Delta := %A_Now%
EnvSub Delta, %last_heist_grab%, hours
if (last_heist_grab = 0 or Delta > 1)
{
UrlDownloadToFile, %heist_price_txt%, local_heists.txt
last_heist_grab = %A_Now%
}
FileRead, HeistFile, local_heists.txt
return HeistFile
}
if (FileExist(heist_price_txt))
{
FileRead, HeistFile, %heist_price_txt%
return HeistFile
}
return ""
}
getGeneralEnchants(general_enchants_txt)
{
if (SubStr(general_enchants_txt,1,4) = "http")
{
global last_enchant_grab
Delta := %A_Now%
EnvSub Delta, %last_enchant_grab%, hours
if (last_enchant_grab = 0 or Delta > 1)
{
UrlDownloadToFile, %general_enchants_txt%, local_general_enchants.txt
last_enchant_grab = %A_Now%
}
FileRead, EnchantFile, local_general_enchants.txt
return EnchantFile
}
if (FileExist(general_enchants_txt))
{
FileRead, EnchantFile, %general_enchants_txt%
return EnchantFile
}
return ""
}
addOption(sect, set_name, offset, title)
{
global
IniRead, TmpName, %SettingsPath%, %sect%, %set_name%
Gui, add, text, x15 y%offset% w280 Right, %title%:
Gui, add, edit, x300 y%offset% w400 v_%sect%_%set_name%, %TmpName%
out := offset + 30
return %out%
}
saveOption(sect, set_name, offset, title)
{
GuiControlGet, TmpName,, _%sect%_%set_name%, value
IniWrite, %TmpName%, %SettingsPath%, %sect%, %set_name%
}
grabScreen(whitelist) {
Gui, EnchantressUI:Hide
coordTemp := SelectArea()
x_start := coordTemp[1]
y_start := coordTemp[3]
x_end := coordTemp[2]
y_end := coordTemp[4]
;WinActivate, Path of Exile
sleep, 500
Tooltip, Please Wait
command = Capture2Text/Capture2Text.exe -s `"%x_start% %y_start% %x_end% %y_end%`" -o `"%TempPath%`" -l English --trim-capture -b --whitelist `"%whitelist%`"
RunWait, %command%
sleep, 1000
WinActivate, ahk_pid %PID%
Tooltip
if (!FileExist(TempPath)) {
MsgBox, - Unable to create temp.txt
return false
}
global RawCaptureTime
global RawTextCapture
FileRead, RawTextCapture, %tempPath%
FormatTime, RawCaptureTime,, yyyy_MM_dd_HH_mm_ss
GuiControl,, CaptureS, %RawTextCapture%
if (checkUpdate())
{
global show_update
if (!show_update)
{
MsgBox A new version of the tool is available, check https://github.com/LawTotem/PoE-Enchantress/releases
show_update := true
}
GuiControl, Text, versiontext, PoE-Enchantress v%version% Update
}
return true
}
cleanString(instring){
output := StrReplace(instring, " ")
output := StrReplace(output, "`r")
output := StrReplace(output, "`n")
return output
}
enchantSort() {
GuiControlGet, EnchantString,, CaptureS, value
IniRead, SaveEnchant, %SettingsPath%, User, SaveEnchant
if (SaveEnchant)
{
EnchantFileName := "enchant_" RawCaptureTime ".txt"
FileDelete, %EnchantFileName%
FileAppend, %EnchantString%, %EnchantFileName%
}
loop, 20
{
GuiControl,, enchant_%A_Index%,
}
current_row := 1
IniRead, ServiceEnchantTxt, %SettingsPath%, User, ServiceEnchantTxt
if (FileExist(ServiceEnchantTxt))
{
FileRead, ServiceFile, %ServiceEnchantTxt%
loop, parse, ServiceFile, `n, `r
{
enchantLine := % A_LoopField
enchantarray := StrSplit(enchantLine, ":")
if (InStr(cleanString(EnchantString), cleanString(enchantarray[1]), false))
{
if (current_row <= 15)
{
GuiControl,, enchant_%current_row%, % enchantarray[2]
}
current_row := current_row + 1
}
}
} else {
GuiControl,, enchant_%current_row%, No Service File
current_row := current_row + 1
}
IniRead, GeneralEnchantTxt, %SettingsPath%, User, GeneralEnchantTxt
GeneralFile := getGeneralEnchants(GeneralEnchantTxt)
if (StrLen(GeneralFile) > 0)
{
loop, parse, GeneralFile, `n, `r
{
enchantLine := % A_LoopField
enchantarray := StrSplit(enchantLine, ":")
if (InStr(cleanString(EnchantString), cleanString(enchantarray[1]), false))
{
if (current_row <= 15)
{
GuiControl,, enchant_%current_row%, % enchantarray[2]
}
current_row := current_row + 1
}
}
} else {
GuiControl,, enchant_%current_row%, No General Enchant File
current_row := current_row + 1
}
if (current_row > 15)
{
msgbox, To many enchant entries (some may have been lost).
}
return true
}
heistSort() {
GuiControlGet, HeistString,, CaptureS, value
loop, 20
{
GuiControl,, enchant_%A_Index%,
}
IniRead, HeistPriceTxt, %SettingsPath%, User, HeistPriceTxt
current_row := 1
HeistFile := getHeistPrices(HeistPriceTxt)
if (StrLen(HeistFile) > 0)
{
loop, parse, HeistFile, `n, `r
{
heistLine := % A_LoopField
heistarray := StrSplit(heistLine, ":")
if (InStr(cleanString(HeistString), cleanString(heistarray[1]), false))
{
if (current_row <= 15)
{
GuiControl,, enchant_%current_row%, % heistarray[1] " ==Price== " heistarray[2]
}
current_row := current_row + 1
}
}
}
else
{
GuiControl,, enchant_1, No Heist Prices Found
}
if (current_row > 15)
{
msgbox, To many heist price entries (some may have been lost) (this shouldnt happen).
}
return true
}
IsGuiVisible(guiName) {
Gui, %guiName%: +HwndguiHwnd
return DllCall("User32\IsWindowVisible", "Ptr", guiHwnd)
}
checkFiles() {
if (!FileExist("Capture2Text")) {
if (FileExist("Capture2Text.exe")) {
msgbox, Looks like you put PoE-Enchantress into the Capture2Text folder`r`nThis is wrong`r`nTake the file out of this folder
ExitApp
} else {
msgbox, Capture2Text folder is missing, did you download the tool?
ExitApp
}
}
if (!FileExist(SettingsPath)) {
msgbox, PoE-Enchantress is in a write protected place on your PC.`r`nIt needs to be able to write some files to the directory.
ExitApp
}
return true
}
monitorInfo(num) {
SysGet, Mon2, monitor, %num%
x := Mon2Left
y := Mon2Top
height := abs(Mon2Top-Mon2Bottom)
width := abs(Mon2Left-Mon2Right)
return [x,y,height,width]
}
global SelectAreaEscapePressed := false
SelectAreaEscape:
SelectAreaEscapePressed := true
Return
CheckError(name, code) {
if (code == 0) {
} else if (code == -1) {
msgbox, %name% Bad Parameter (-1)
} else if (code == -2) {
msgbox, %name% Return Type is invalid (-2)
} else if (code == -3) {
msgbox, %name% DLL could not be found (-3)
} else if (code == -4) {
msgbox, %name% Function could not be found (-4)
}
}
CaptureAreaWin(x, y, w, h) {
FormatTime, dtg,, yyyy_MM_dd_HH_mm_ss
file_name := "snap_" dtg ".png"
DllCall("snipper\SnipAndSave","Int",x,"Int",y,"Int",w,"Int",h,"Str",file_name)
CheckError("Snipper", ErrorLevel)
}
SelectArea() {
iniRead tempMon, %SettingsPath%, Other, monitor
iniRead, scale, %SettingsPath%, Other, scale
cover := monitorInfo(tempMon)
coverX := cover[1]
coverY := cover[2]
coverH := cover[3] / scale
coverW := cover[4] / scale
Gui, Select:New
Gui, Color, 141414
Gui, +LastFound +ToolWindow -Caption +AlwaysOnTop
WinSet, Transparent, 120
Gui, Select:Show, x%coverX% y%coverY% h%coverH% w%coverW%, "AutoHotkeySnapshotApp"
; Waiting for the initial keypress
isLButtonDown := false
SelectAreaEscapePressed := false
Hotkey, Escape, SelectAreaEscape, On
while (!isLButtonDown and !SelectAreaEscapedPressed) {
KeyWait, LButton, D T0.1
isLButtonDown := (ErrorLevel == 0)
}
; Starting the rectangle draw
areaRect := []
if (!SelectAreaEscapePressed) {
CoordMode, Mouse, Screen
MouseGetPos, MX, MY
CoordMode, Mouse, Relative
MouseGetPos, rMX, rMY
CoordMode, Mouse, Screen
c := "Blue"
t := "40"
g := "99"
m := "s"
Gui %g%: Destroy
Gui %g%: +AlwaysOnTop -Caption +Border +ToolWindow +LastFound
WinSet, Transparent, %t%
Gui %g%: Color, %c%
; Draw the window accounting for top left to bottom right or bottom right to top left
while (GetKeyState("LButton") and !SelectAreaEscapePressed) {
sleep, 10
MouseGetPos, MXend, MYend
w := abs((MX / scale) - (MXend / scale))
h := abs((MY / scale) - (MYend / scale))
X := (MX < MXend) ? MX : MXend
Y := (MY < MYend) ? MY : MYend
Gui %g%: Show, x%X% y%Y% w%w% h%h% NA
}
Gui %g%: Destroy
if (!SelectAreaEscapePressed) {
MouseGetPos, MXend, MYend
if (MX > MXend) {
temp := MX
MX := MXend
MXend := temp
}
if (MY > MYend) {
temp := MY
MY := MYend
MYend := temp
}
areaRect := [MX, MXend, MY, MYend]
}
}
Hotkey, Escape, SelectAreaEscape, Off
Gui, Select:Destroy
IniRead, SnapshotScreen, %SettingsPath%, User, SnapshotScreen
if (SnapshotScreen) {
CaptureAreaWin(MX,MY, MXend - MX, MYend - MY)
}
Gui, EnchantressUI:Default
return areaRect
}
checkUpdate() {
global last_version_grab
Delta := %A_Now%
EnvSub Delta, %last_version_grab%, hours
if (last_version_grab = 0 or Delta > 1)
{
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.Open("Get","https://raw.githubusercontent.com/LawTotem/PoE-Enchantress/dev/version.txt", true)
whr.Send()
whr.WaitForResponse()
online_version := whr.ResponseText()
last_version_grab = %A_Now%
if (online_version > version)
{
return true
}
}
return false
}