# Macro that disable / enable sound device in Windows 7

What should I use to program that kind of Macro ?

-

Autohotkey!

Look up the "SoundSet" function to achieve what you want here.

-
Can I do this without a program like AutoHotKey, I can do macros with my Razer Tarantula I'd like to use that if possible –  Peter Oct 26 '09 at 0:23
You asked what program you could do it with, I gave you an answer. If you don't want a certain type of answer, put that in the question, Razer Tarantula we're not telepaths. I've never used such a keyboard, so I don't know, but AHK would still be fit for the task. –  Phoshi Oct 26 '09 at 0:55
I'm trying at the moment and I can't seem to make it work with Windows 7 sound devices –  Peter Oct 26 '09 at 0:59
I listed all the sound devices, a few are there but not the one I want to change settings, I'm using USB headphones –  Peter Oct 26 '09 at 1:04

You may use devcon from Microsoft

The DevCon utility is a command-line utility that acts as an alternative to Device Manager. Using DevCon, you can enable, disable, restart, update, remove, and query individual devices or groups of devices. DevCon also provides information that is relevant to the driver developer and is not available in Device Manager.

the page contain a detailed set of information about how to use it,

devcon find *

To lists device instances of all devices that are present on the local computer.then,

devcon disable <your-sound-card-HardwareID>

to disable devices that match the specific hardware or instance ID,you can use wildcard (*)

-

Find what registry values your particular Macro queries, you can do this with Sysinternals Process Monitor.

For me, the calculator key on my keyboard queries the value of

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AppKey\18\ShellExecute

which is set to "calc.exe".

Change that value to use NirCmd to mute the device or the previously mentioned DevCon to disable the device.

example:

to mute

C:\path\to\nircmd.exe mutesysvolume 1

to unmute

C:\path\to\nircmd.exe mutesysvolume 0

or to disable

devcon disable [hardware_id]

and re-enable

devcon enable [hardware_id]
-