-
Notifications
You must be signed in to change notification settings - Fork 11
/
ToggleGui.ahk
42 lines (34 loc) · 1.1 KB
/
ToggleGui.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
#Requires AutoHotkey v2.0
full_command_line := DllCall("GetCommandLine", "str")
if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
{
try
{
if A_IsCompiled
Run '*RunAs "' A_ScriptFullPath '" /restart'
else
Run '*RunAs "' A_AhkPath '" /restart "' A_ScriptFullPath '"'
}
ExitApp
}
MyGui := Gui(, "Toggle Loudness Equalisation")
MyBtn := MyGui.Add("Button", "w100 h50", "Toggle")
ToggleLoudness(*)
{
playbackDeviceName := EnvGet("HeadphonesName")
releaseTime := EnvGet("ReleaseTime")
if !playbackDeviceName
{
MsgBox("Error: HeadphonesName environment variable not set.")
return
}
if !releaseTime
{
MsgBox("Error: ReleaseTime environment variable not set.")
return
}
; The script is assumed to be in the same directory as the AHK script or in the PATH
Run('powershell.exe -WindowStyle hidden -File "ToggleLoudness.ps1" -playbackDeviceName "' playbackDeviceName '" -maxDeviceCount 1 -releaseTime ' releaseTime)
}
MyBtn.OnEvent("Click", ToggleLoudness)
MyGui.Show("w400 h100")