-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAPOpreamp.ahk
59 lines (50 loc) · 3.64 KB
/
APOpreamp.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
global TargetFile := "C:\Program Files\EqualizerAPO\config\DynamiQ-master\Gain.txt" ;The script will write to this config file.
global Gain := 0 ;Initialize integer 'Gain' with value 0.
WriteConfig() ;Apply the initialized value.
CoordMode, ToolTip ;Set the ToolTip to Coordinate Mode to make it show at an absolute position on the screen.
;Adding the $ before the hotkey to prevent looping when the hotkey sends itself.
$Volume_Up:: ;When Volume Up is pressed,
SoundGet, SystemVolume ;Find out what the current system volume is.
if (SystemVolume = 100) { ;If System Volume is maxed out but Gain is not,
if (Gain < 50) {
Gain++ ;Increase the Gain by 1dB,
WriteConfig() ;And write that into the config using the WriteConfig function,
}
ShowGain() ;Use the ShowGain function to display the Gain value in a ToolTip.
}
else { ;But if System Volume is not maxed out,
Send {Volume_Up} ;Increase System Volume normally.
}
return ;End of this hotkey.
$Volume_Down:: ;When Volume Down is pressed,
if (Gain > 0) { ;If the Gain is not already 0,
Gain-- ;Decrease the Gain by 1dB,
WriteConfig() ;And write that into the config using the WriteConfig function.
ShowGain() ;Use the ShowGain function to display the Gain value in a ToolTip.
}
else { ;Otherwise (if Gain is already 0),
Send {Volume_Down} ;Decrease System Volume normally.
}
return ;End of this hotkey.
ShowGain() {
; Get screen dimensions
SysGet, MonitorWorkArea, MonitorWorkArea, 1
MonitorWidth := MonitorWorkAreaRight - MonitorWorkAreaLeft
MonitorHeight := MonitorWorkAreaBottom - MonitorWorkAreaTop
; Calculate tooltip position
TooltipWidth := 120 ; Adjust the width as needed
TooltipHeight := 20 ; Adjust the height as needed
TooltipX := ((MonitorWidth // 2) - (TooltipWidth // 2)) + 30 ; Center horizontally
TooltipY := MonitorWorkAreaBottom - TooltipHeight - 65 ; Align to the bottom with 65 pixels padding
ToolTip, Gain: %Gain%, TooltipX, TooltipY, , Segoe UI ; Show the Gain value in a ToolTip at the center bottom with padding using Segoe UI font
SetTimer, RemoveToolTip, -1000 ; Set a 1000ms timer for the ToolTip.
return
RemoveToolTip: ; Auto-disappear the ToolTip.
ToolTip
return
}
WriteConfig() { ;The function 'WriteConfig' takes care of writing changes to the config file.
FileDelete, %TargetFile%.tmp.txt ;Delete the old config file in preparation for rewrite.
FileAppend, Preamp: %Gain% dB, %TargetFile%.tmp.txt ;Write to a Temp File first,
FileCopy, %TargetFile%.tmp.txt, %TargetFile%, 1 ;Then overwrite the Target File with the Temp File,
} ;To make the volume adjustment process smoother and reduce popping noises.