forked from JusKillmeQik/PoE-Leveling-Guide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LevelingGuide.ahk
305 lines (260 loc) · 7.79 KB
/
LevelingGuide.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
#SingleInstance, force
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;Check version and download if OK
version_array := StrSplit(A_AhkVersion, ".")
If (version_array[1] != 1 or version_array[2] != 1){
MsgBox, 1,, Your version of AutoHotkey is: %A_AhkVersion%, Please download the latest version of Autohotkey 1.1
IfMsgBox, OK
Run, https://www.autohotkey.com/download/ahk-install.exe
ExitApp
} Else If (version_array[3] < 30) {
MsgBox, 1,, Your version of AutoHotkey is: %A_AhkVersion%, Please download the latest version of Autohotkey
IfMsgBox, OK
Run, https://www.autohotkey.com/download/ahk-install.exe
ExitApp
}
#Include, %A_ScriptDir%\lib\JSON.ahk
#Include, %A_ScriptDir%\lib\Gdip.ahk
;Menu
Menu, Tray, NoStandard
Menu, Tray, Tip, PoE Leveling Guide
Menu, Tray, Add, Settings, LaunchSettings
Menu, Tray, Add, Edit Build, LaunchBuild
Menu, Tray, Add
Menu, Tray, Add, Reload, PLGReload
Menu, Tray, Add, Close, PLGClose
; Icons
Menu, Tray, Icon, %A_ScriptDir%\icons\lvlG.ico
Menu, Tray, Icon, Settings, %A_ScriptDir%\icons\gear.ico
Menu, Tray, Icon, Reload, %A_ScriptDir%\icons\refresh.ico
Menu, Tray, Icon, Close, %A_ScriptDir%\icons\x.ico
global PoEWindowGrp
GroupAdd, PoEWindowGrp, Path of Exile ahk_class POEWindowClass ahk_exe PathOfExile.exe
GroupAdd, PoEWindowGrp, Path of Exile ahk_class POEWindowClass ahk_exe PathOfExile_KG.exe
GroupAdd, PoEWindowGrp, Path of Exile ahk_class POEWindowClass ahk_exe PathOfExileSteam.exe
GroupAdd, PoEWindowGrp, Path of Exile ahk_class POEWindowClass ahk_exe PathOfExile_x64.exe
GroupAdd, PoEWindowGrp, Path of Exile ahk_class POEWindowClass ahk_exe PathOfExile_x64_KG.exe
GroupAdd, PoEWindowGrp, Path of Exile ahk_class POEWindowClass ahk_exe PathOfExile_x64Steam.exe
global data := {}
Try {
FileRead, JSONFile, %A_ScriptDir%\lib\data.json
data := JSON.Load(JSONFile)
If (not data.p1acts.Length()) {
MsgBox, 16, , Error reading zone data! `n`nExiting script.
ExitApp
}
} Catch e {
MsgBox, 16, , % e "`n`nCould not read data file: Exiting script."
ExitApp
}
#Include, %A_ScriptDir%\lib\config.ahk
#Include, %A_ScriptDir%\lib\settings.ahk
#Include, %A_ScriptDir%\lib\sizing.ahk
global PoEWindowHwnd := ""
WinGet, PoEWindowHwnd, ID, ahk_group PoEWindowGrp
global old_log := ""
global trigger := false
global onStartup := 1
#Include, %A_ScriptDir%\lib\draw.ahk
DrawZone()
DrawTree()
DrawExp()
#Include, %A_ScriptDir%\lib\set.ahk
SetNotes()
SetGuide()
SetGems()
#Include, %A_ScriptDir%\lib\hotkeys.ahk
Gosub, HideAllWindows
ToggleLevelingGuide()
SetTimer, ShowGuiTimer, 200, -100
Return
;========== Subs and Functions =======
#Include, %A_ScriptDir%\lib\search.ahk
ShowGuiTimer:
poe_active := WinActive("ahk_id" PoEWindowHwnd)
controls_active := WinActive("ahk_id" . Controls) ; Wow that dot is important!
level_active := WinActive("ahk_id" . Level)
gems_active := WinActive("ahk_id" . Gems)
If (activeCount <= displayTimeout) {
active_toggle := 1
If (!controls_active) {
activeCount++
}
} Else if (activeCount = displayTimeout + 1) {
GoSub, HideAllWindows
active_toggle := 0
activeCount++
}
If (controls_active or displayTimeout=0) {
activeCount := 0
active_toggle := 1
}
;This shows the guide if you put your mouse in the top right corner, it triggers too often and isn't helpful
; MouseGetPos, xposMouse, yposMouse
; If (yposMouse < 10 and xposMouse > A_ScreenWidth-Round(A_ScreenWidth/4)) {
; activeCount := 0
; active_toggle := 1
; }
If (poe_active or controls_active or level_active or gems_active) {
; show all gui windows
GoSub, ShowAllWindows
Sleep 500
} Else {
GoSub, HideAllWindows
;Reset activity upon return
activeCount := 0
active_toggle := 1
}
While true
{
;The PoEWindow doesn't stay active through a restart, so must wait for it to be open
closed := 0
Process, Exist, PathOfExile.exe
If(!errorlevel) {
closed++
} Else {
client := GetProcessPath( "PathOfExile.exe" )
StringTrimRight, client, client, 15
client .= "logs\Client.txt"
}
Process, Exist, PathOfExileSteam.exe
If(!errorlevel) {
closed++
} Else {
client := GetProcessPath( "PathOfExileSteam.exe" )
StringTrimRight, client, client, 20
client .= "logs\Client.txt"
}
Process, Exist, PathOfExile_KG.exe
If(!errorlevel) {
closed++
} Else {
client := GetProcessPath( "PathOfExile_KG.exe" )
StringTrimRight, client, client, 18
client .= "logs\Client.txt"
}
Process, Exist, PathOfExile_x64.exe
If(!errorlevel) {
closed++
} Else {
client := GetProcessPath( "PathOfExile_x64.exe" )
StringTrimRight, client, client, 19
client .= "logs\Client.txt"
}
Process, Exist, PathOfExile_x64Steam.exe
If(!errorlevel) {
closed++
} Else {
client := GetProcessPath( "PathOfExile_x64Steam.exe" )
StringTrimRight, client, client, 24
client .= "logs\Client.txt"
}
Process, Exist, PathOfExile_x64_KG.exe
If(!errorlevel) {
closed++
} Else {
client := GetProcessPath( "PathOfExile_x64_KG.exe" )
StringTrimRight, client, client, 22
client .= "logs\Client.txt"
}
If (closed = 6){
GoSub, HideAllWindows
;Sleep 10 seconds, no need to keep checking this
Sleep 10000
;Reset activity upon return
activeCount := 0
active_toggle := 1
} Else {
If (onStartup) {
;Delete Client.txt on startup so we don't have to read a HUGE file!
FileGetSize, clientSize, %client%, K ; Retrieve the size in Kbytes.
If(clientSize > 100000){
MsgBox, 1,, Your %client% is over 100Mb and will be deleted to speed up this script. Feel free to Cancel and rename the file if you want to keep it, but deletion will not affect the game at all.
IfMsgBox Ok
{
file := FileOpen(client, "w")
If IsObject(file) {
file.Close()
}
}
}
onStartup := 0
}
WinGet, PoEWindowHwnd, ID, ahk_group PoEWindowGrp
break
}
} ;End While
;Magic
SearchLog()
return
ShowAllWindows:
If (LG_toggle and active_toggle) {
Gui, Controls:Show, NoActivate
}
controls_active := WinActive("ahk_id" Controls)
If (LG_toggle and !controls_active and (active_toggle or persistText = "True") and numPart != 3) {
Gui, Notes:Show, NoActivate
Gui, Guide:Show, NoActivate
} Else If (!controls_active) {
Gui, Notes:Cancel
Gui, Guide:Cancel
}
If (zone_toggle) {
;UpdateImages()
Loop, % maxImages {
Gui, Image%A_Index%:Show, NoActivate
}
} else {
Loop, % maxImages {
Gui, Image%A_Index%:Cancel
}
}
If (tree_toggle) {
Gui, Tree:Show, NoActivate
} Else If (level_toggle) {
Gui, Level:Show, NoActivate
SetExp()
}
If (gems_toggle) {
Gui, Gems:Show, NoActivate
Gui, Links:Show, NoActivate
}
return
HideAllWindows:
Gui, Controls:Cancel
Gui, Level:Cancel
Gui, Exp:Cancel
Loop, % maxImages {
Gui, Image%A_Index%:Cancel
}
Gui, Notes:Cancel
Gui, Guide:Cancel
Gui, Tree:Cancel
Gui, Gems:Cancel
Gui, Links:Cancel
return
Tail(k,file) { ; Return the last k lines of file
Loop Read, %file%
{
i := Mod(A_Index,k)
L%i% = %A_LoopReadLine%
}
L := L%i%
Loop % k-1
{
IfLess i,1, SetEnv i,%k%
i-- ; Mod does not work here
L := L%i% "`n" L
}
Return L
}
GetProcessPath(exe) {
for process in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process where name ='" exe "'")
return process.ExecutablePath
}
PLGReload:
Reload
PLGClose:
ExitApp