SoundVol plugin for Take Command / TCC / TCC/LE
Version 1.1.0 2024-09-24
Charles Dye
Purpose:
This plugin supplies a replacement _VOLUME
variable which will work under Windows Vista and later. For bonus points,
it also supplies a _MUTE
variable to
return the mute state, and a SOUNDVOL
command to report or change the master volume and mute state.
There is also a new DEFAUDIOOUT
command to display or change the default audio output device, and a
_DEFAUDIOOUT
variable to return
the name of the current default audio output device.
(This is really just the sound volume features from my UIStuff plugin, diked out and rolled into a separate little plugin.)
Installation:
To use this plugin, copy SoundVol.dll to
some known location on your hard drive. (If you are still using the 32-bit
version of Take Command, take SoundVol-x86.dll
instead of SoundVol.dll.) Load the .DLL file
with a PLUGIN /L
command, for example:
plugin /l c:\bin\tcmd\test\soundvol.dll
If you copy the .DLL file to a subdirectory named PlugIns within your Take Command program directory, it will be loaded automatically when TCC starts.
Plugin Features:
New commands: DEFAUDIOOUT
,
SOUNDVOL
New variables: _DEFAUDIOOUT
,
_MUTE
, _VOLUME
Syntax Note:
The syntax definitions in the following text use these conventions for clarity:
BOLD CODE | indicates text which must be typed exactly as shown. |
CODE | indicates optional text, which may be typed as shown or omitted. |
Bold italic | names a required argument; a value must be supplied. |
Regular italic | names an optional argument. |
ellipsis… | after an argument means that more than one may be given. |
Examples are shown in a gray box:
rem This is an example:
soundvol /o 85
Some command options take an argument. These are shown with a colon between the
option and its argument: /A:
arg
If you like, you may substitute an equals sign for the colon: /A=
arg
This is handy if the arg is a filename, and you want to use tab completion to
enter the filename.
Or you can omit the colon: /A
arg
New Commands:
DEFAUDIOOUT
— Display or change
the default audio output device.
Syntax:
DEFAUDIOOUT
/Q
device
/Q | quietly |
device | the device’s name, or its index 1 - n |
If you do not specify a device,
DEFAUDIOOUT
will display a list of available audio outputs.
rem Use my monitor for audio output:
defaudioout "dell u3415w*"
• Note: This command requires Windows Vista or later; it will not work in Windows XP.
SOUNDVOL
— Display or change the
master sound volume.
Syntax:
SOUNDVOL
/B /M /O /Q /U
volume
/B | beep after changing settings |
/M | mute the sound |
/O | display the current settings on-screen |
/Q | quietly |
/U | unmute the sound |
volume | new volume level, 0 — 100 |
Unless /Q
is specified, the current volume will be displayed.
rem Crank it all the way up:
soundvol /u 100
New Variables:
_DEFAUDIOOUT
— Returns the name
of the current default audio output device.
Syntax:
%_DEFAUDIOOUT
The returned name will probably contain spaces and maybe weirder stuff, so it might be a good idea to quote it.
rem Save the current setting:
set oldaudioout="%_defaudioout"
rem ...and restore it later:
defaudioout %oldaudioout
• Note: This variable requires Windows Vista or later; it will not work in Windows XP.
_MUTE
— Returns the master
sound mute state.
Syntax:
%_MUTE
The value returned is 1
if the sound is muted, or 0
otherwise. If the current volume level cannot be determined (e.g.
there is no sound hardware installed), this variable will return
-1
.
rem Check whether the audio is muted:
if %_mute == 1 echo The audio is muted.
_VOLUME
— Returns the
master sound volume level.
Syntax:
%_VOLUME
The value returned is in the range 0 through 100. If the current volume
level cannot be determined, this variable will return -1
.
rem Display the current master volume level:
echo The master sound volume is at %_volume.
Startup Message:
This plugin displays an informational line when it initializes. The
message will be suppressed in transient or pipe shells. You can disable it
for all shells by defining an environment variable named NOLOADMSG
,
for example:
set /e /u noloadmsg=1
Acknowledgments:
The Windows XP (and earlier) mixer API is the kind of Byzantine, bodged-together Rube Goldberg monstrosity that gives “crawling horror” a bad name. This page (by Alberto di Bene?) was instrumental in saving my sanity.
… And then Microsoft said “Let there be Vista.” And lo, there was much confusion. Setting the master volume using the old API doesn’t work in Vista and later. The new interface is much simpler to use, and this page (by Sayyeid Mostafa Hashemi) was extremely helpful to me in making it work. Of course, the new Vista method won’t work in Windows XP and earlier; so this plugin must incorporate two utterly different routines to get and set the volume and mute state. Isn’t Windows amazing?
It seems that Microsoft doesn’t want us to change the default audio device programatically. Why not? I don’t know. I don’t care. I have perfectly valid reasons for wanting to do this; maybe you do too. To do the seemingly impossible I am using IPolicyConfig.h by EreTIk, which I found here. Thank you, EreTIk, whoever you are.
Changes:
Version: | Date: | Changes: |
---|---|---|
1.1.0 | 2024-09-24 | Added DEFAUDIOOUT
and _DEFAUDIOOUT . |
1.0.0.2 | 2023-10-16 | Tweaked ShowCmdHelp() to include
VER_PATCH . |
1.0.0.1 | 2023-10-12 | Updated the plugin’s web address. |
1.0.0 | 2023-07-06 | First release. Updated OsdCmd.cpp; removed the need for FindMyWindow.cpp and made the .DLL files about 1½ K smaller. |
Status and Licensing:
This plugin is © Copyright 2025, Charles Dye. Unaltered copies of the binary and documentation files may be freely distributed without restriction. I make no guarantee and give no warranty for its operation. If you find a problem, you can report it in the JP Software support forum.
Download:
You can download the current version of the plugin from https://charlesdye.net/dl/soundvol.zip.