-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_(RUN THIS FILE) Displaced GRID for Warcraft III.ahk
380 lines (283 loc) · 9.94 KB
/
_(RUN THIS FILE) Displaced GRID for Warcraft III.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
;-----------------------------------------
; Displaced Grid for Warcraft III:Reforged by etofok
; Website Overview: https://etofok.github.io/Displaced-Grid-for-Warcraft-III/web/index
; Download Latest: https://github.com/etofok/Displaced-Grid-for-Warcraft-III
; Development:
; Dec 10th, 2023 - Sept 24th, 2024
;-----------------------------------------
#SingleInstance force
#NoEnv
#Persistent
if not A_IsAdmin
Run *RunAs "%A_ScriptFullPath%"
Global currentVersion := "v1.3.3"
Global winTitle := "ahk_class OsWindow" ; Warcraft III class name, as seen in WindowSpy of AutoHotkey
Global winName := "Warcraft III" ; Warcraft III window name, as seen in WindowSpy of AutoHotkey
SetWorkingDir %A_ScriptDir%
SetTitleMatchMode, 3
; miscellaneous
Global FlashSplashTime := 150
Global PortraitUI := []
Global error_warcraftNotFound := "App is active but Warcraft III is NOT FOUND`n`nTo use Displaced Grid hotkeys`nplease launch Warcraft III and try again!"
#Include *i %A_ScriptDir%\Modules\layout_Start.ahk
#Include *i %A_ScriptDir%\_UserSettings.ahk
#include *i %A_ScriptDir%\Modules\layout_BlizzardGrid.ahk
#include *i %A_ScriptDir%\Modules\layout_DisplacedGrid.ahk
#include *i %A_ScriptDir%\Modules\layout_SetHotkeys.ahk
#Include *i %A_ScriptDir%\Modules\Hotkey_CommandCard.ahk
#Include *i %A_ScriptDir%\Modules\Hotkey_ControlGroup.ahk
#Include *i %A_ScriptDir%\Modules\Hotkey_Item.ahk
Hotkey, %Hotkey_Toggle_DisplacedGrid%, Toggle_DisplacedGrid, UseErrorLevel
Hotkey, %Hotkey_ScriptReload%, ScriptReload, UseErrorLevel
Hotkey, %Hotkey_Send_glhf%, Send_glhf, UseErrorLevel
Hotkey, %Hotkey_Send_gg%, Send_gg, UseErrorLevel
Hotkey, IfWinActive, ahk_class OsWindow
;-----------------------------------------
; App control hotkeys
;-----------------------------------------
Tooltip_Hotkey_Toggle_DisplacedGrid := ReplaceModifiers(Hotkey_Toggle_DisplacedGrid)
Tooltip_Hotkey_ScriptReload := ReplaceModifiers(Hotkey_ScriptReload)
Global menu_Toggle_DisplacedGrid := "Displaced Grid <" . Tooltip_Hotkey_Toggle_DisplacedGrid . ">"
Global menu_ScriptReload := "Restart Application <" . Tooltip_Hotkey_ScriptReload . ">"
Global menu_ScriptSettings := "Open Settings"
Global menu_ScriptFolder := "Open Folder"
;-----------------------------------------
; Tray Menu
;-----------------------------------------
Menu, Tray, NoStandard
Menu, Tray, Tip, Displaced Grid+ %currentVersion% by etofok
Menu, Tray, Add, Displaced GRID+ %currentversion% by etofok, handler_blank
Menu, Tray, Disable, Displaced GRID+ %currentversion% by etofok
Menu, Tray, Add, etofok Link Tree >>, LinkTree
Menu, Tray, Add, ,
Menu, Tray, Add, Toggle Hotkey Layout, handler_blank
Menu, Tray, Disable, Toggle Hotkey Layout
Menu, Tray, Add, %menu_Toggle_DisplacedGrid%, Toggle_DisplacedGrid
Menu, Tray, Default, %menu_Toggle_DisplacedGrid%,
if (b_EventLog == True) {
#Include *i %A_ScriptDir%\Modules\module_EventLog.ahk
}
Menu, Tray, Add, ,
Menu, Tray, Add, MODULES, handler_blank
Menu, Tray, Disable, MODULES
; ADDING MODULES ONE BY ONE...
#Include *i %A_ScriptDir%\Modules\module_RapidFire.ahk
#Include *i %A_ScriptDir%\Modules\module_CameraHotkeys.ahk
#Include *i %A_ScriptDir%\Modules\module_CommandMultipleGroups.ahk
#Include *i %A_ScriptDir%\Modules\module_ShiftQueueItems.ahk
#Include *i %A_ScriptDir%\Modules\module_QuickCastItems.ahk
#Include *i %A_ScriptDir%\Modules\module_QuickDropItems.ahk
#Include *i %A_ScriptDir%\Modules\module_AltKeyImprovements.ahk
Menu, Tray, Add, ,
Menu, Tray, Add, SET UP, handler_blank
Menu, Tray, Disable, SET UP
Menu, Tray, Add, %menu_ScriptSettings%, ScriptSettings
Menu, Tray, Add, How to enable QuickCast for Abilities, Tutorial_AbilityQuickCast
Menu, Tray, Add, How to align the overlay, Tutorial_Overlay
Menu, Tray, Add, Go to Website, Tutorial_Website
Menu, Tray, Add, ,
Menu, Tray, Add, %menu_ScriptReload%, ScriptReload
Menu, Tray, Add, %menu_ScriptFolder%, ScriptFolder
Menu, Tray, Add, Exit, ScriptExit
;-----------------------------------------
; ----- L A U N C H -----
;-----------------------------------------
if (false) {
} ; this is actually an important line of code
; Greetings and Satulations
displaySplash := "Displaced Grid for Warcraft III: Reforged`nby etofok`n`nTOGGLE HOTKEY: `n" . Tooltip_Hotkey_Toggle_DisplacedGrid
SplashTextOn, 300, 120, , %displaySplash%
Sleep, 1500
SplashTextOff
; load Image_Overlay at the very end
#Include *i %A_ScriptDir%\Modules\module_Overlay.ahk
; ?Should we activate Displaced Grid hotkeys on app start?
if (b_DisplacedGrid == 1) {
if WinExist(winTitle) {
Control_DisplacedGrid(1) ; Toggle On on start ONLY if the Warcraft III window exists
} else {
Control_DisplacedGrid(0) ; Force Toggle Off if the Warcraft III window does not exist
}
} else {
Control_DisplacedGrid(0) ; otherwise don't enable the hotkeys on launch
}
;--------------------
; --- E N D O F A U T O L A U N C H ---
;-----------------------------------------
;-----------------------------------------
return ; this return is the most important line of code
; all modules get added in the autorun section above
#IfWinActive
;--------------------------------
; DisplacedGrid Control
;--------------------------------
Toggle_DisplacedGrid() {
if (b_DisplacedGrid == 1) {
;turn off the DGRID Layout
Control_DisplacedGrid(0)
; Crutch to link Displaced Grid On/Off with RapidFire module.
; Otherwise you can't type because RapidFire sends a left click as you type, which closes the chat :)
Control_RapidFire(0)
;turn off Image_Overlay.png
Control_Overlay(0)
} else {
if WinExist(winTitle) {
;turn on the DGRID Layout
Control_DisplacedGrid(1)
; Crutch to link Displaced Grid On/Off with RapidFire module.
; Otherwise you can't type because RapidFire sends a left click as you type, which closes the chat :)
Control_RapidFire(1)
;turn on Image_Overlay.png
Control_Overlay(1)
} else {
MsgBox, %error_warcraftNotFound%
}
}
}
Control_DisplacedGrid(switchTo) {
b_DisplacedGrid := switchTo
ReloadHotkeys()
ToggleCheckmark(menu_Toggle_DisplacedGrid, switchTo)
Menu, Tray, Icon, %A_ScriptDir%\Modules\icons\icon_Hotkeys%switchTo%.ico
if (b_EventLog) {
UpdateEventLog("Displaced GRID Keys - " . switchTo)
FlashSplash("Displaced GRID Keys - " . switchTo, FlashSplashTime)
}
}
ReloadHotkeys() {
SetHotkeys(0) ; turn off the current set of active hotkeys
if (b_DisplacedGrid == 0) {
load_BlizzardGrid()
} else {
load_DisplacedGrid()
}
SetHotkeys(1) ; re-assign the hotkeys
}
;----------------------------------------------------------------
; Auxiliary functions
;----------------------------------------------------------------
Send_glhf() {
Send, {Enter}
Sleep, 50
SendRaw, gl hf
Sleep, 50
Send, {Enter}
}
Send_gg() {
Send, {Enter}
Sleep, 50
SendRaw, gg
Sleep, 50
Send, {Enter}
}
;--------------------------------
; Tutorial_AbilityQuickCast
;--------------------------------
Tutorial_AbilityQuickCast:
Suspend, Permit
Run, %a_scriptdir%\Modules\How to enable QuickCasts for Abilities.txt
return
;--------------------------------
; Tutorial_Overlay
;--------------------------------
Tutorial_Overlay:
Suspend, Permit
Run, %a_scriptdir%\Image_Overlay\How to adjust the overlay to your resolution.txt
return
;--------------------------------
; Tutorial_Website
;--------------------------------
Tutorial_Website:
Suspend, Permit
Run, https://etofok.github.io/Displaced-Grid-for-Warcraft-III/web/index.html
return
;--------------------------------
; Reload This Script
;--------------------------------
ScriptReload:
Suspend, Permit
Reload
return
;--------------------------------
; Locate This Script
;--------------------------------
ScriptFolder:
Suspend, Permit
Run, %a_scriptdir%
return
;--------------------------------
; Locate UserSettings
;--------------------------------
ScriptSettings:
Suspend, Permit
filePath := A_ScriptDir "\_UserSettings.ahk"
Run, notepad.exe %filePath%
return
;--------------------------------
; Exit This Script
;--------------------------------
ScriptExit:
Suspend, Permit
ExitApp
return
;----------------------------------------------------------------
;----------------------------------------------------------------
;----------------------------------------------------------------
;--------------------------------
; Get info whether the Shift and/or Ctrl keys are pressed down
;--------------------------------
GetModifiersState() {
if (GetKeyState("Shift", "P")) {
appendModifiers .= "+"
}
if (GetKeyState("Ctrl", "P")) {
appendModifiers .= "^"
}
if (GetKeyState("Alt", "P")) {
appendModifiers .= "!"
}
return appendModifiers
}
;--------------------------------
; Translate Tooltip Hotkeys to Human Language
;--------------------------------
ReplaceModifiers(str) {
; Replace symbols with corresponding names
str := StrReplace(str, "+", "SHIFT + ") ; start with the "+"!
str := StrReplace(str, "!", "ALT + ")
str := StrReplace(str, "^", "CTRL + ")
str := StrReplace(str, "#", "WIN + ")
return str
}
;--------------------------------
; Flash a splash on script launch
;--------------------------------
FlashSplash(displayText, time) {
displayText := StrReplace(displayText, "1", "Activating...")
displayText := StrReplace(displayText, "0", "Deactivating...")
SplashTextOn, 300, 55, , %displayText%
Sleep, %time%
SplashTextOff
}
;--------------------------------
; Toggle Checkmark Func
;--------------------------------
ToggleCheckmark(trayitem, onoff) {
if (onoff == 1) {
Menu, Tray, Check, %trayitem%
} else if (onoff == 0) {
Menu, Tray, Uncheck, %trayitem%
}
}
;--------------------------------
; linktr
;--------------------------------
LinkTree:
Run, https://linktr.ee/etofok
return
;-----------------------------------------
; Blank
;-----------------------------------------
handler_blank() {
}
#IfWinActive