An update is below.
Code: Select all
param = %1%
if (param = "/?")
MsgBox, This program returns an exit code.`n0 = Master volume is unmuted.`n1 = Master volume is muted.`n2 = Volume Mixer window was not found.`n3 = SndVol was not found.
sndvol = SndVol.exe
prog = %WINDIR%\System32\%sndvol%
if !FileExist(prog) ; SndVol was not found.
{
MsgBox, SndVol was not found.
Exit, 3
}
else
{
title = Volume Mixer
Process, Exist, %sndvol%
running = %ErrorLevel%
if running = 0 ; SndVol is not already running.
Run, %prog%, , Min
WinWait, %title%, , 5
if ErrorLevel ; Volume Mixer window was not found.
{
MsgBox, Volume Mixer window was not found.
Exit, 2
}
else ; Volume Mixer window was found.
{
WinGetTitle, fulltitle, %title% ; Get the complete window title.
regExp := title . " - (.+) \(.+"
speaker := RegExReplace(fulltitle, regExp, "$1") ; Find the default speaker's name.
text := "Mute " . speaker
ControlGetText, mute, %text%, %title% ; Figure out if speaker is muted.
if (mute = "")
{
MsgBox, Muted.
code = 1
}
else
MsgBox, Unmuted.
if running = 0 ; SndVol was not originally running.
WinClose, %title%
Exit, code
}
}