Jump to content


Photo

Mute/unmute Microphone device.


  • Please log in to reply
4 replies to this topic

#1 nascent

nascent
  • Members
  • 3 posts

Posted 29 May 2012 - 12:28 PM

I wrote a script for someone to mute and unmute the integrated microphone on their laptop. Obviously any software can re-enable it so it's more a false sense of security if anything, but here's the code: (I should probably point out, this was only tested on Windows 7)

Run, rundll32.exe shell32.dll`,Control_RunDLL mmsys.cpl`,`,1  ; Opens Recorder settings
Sleep, 100
WinWait, Sound, 
IfWinNotActive, Sound, , WinActivate, Sound, 
WinWaitActive, Sound, 
Send, {DOWN 1}{ALTDOWN}p{ALTUP} ; Change the DOWN 1 to the position of your mic in the list.
WinWait, Microphone Properties, 
IfWinNotActive, Microphone Properties, , WinActivate, Microphone Properties, 
WinWaitActive, Microphone Properties, 
Send, {SHIFTDOWN}{TAB  4}{SHIFTUP}{HOME}{ENTER} ; Enable device
;Send, {SHIFTDOWN}{TAB  4}{SHIFTUP}{END}{ENTER} ; Disable device
WinWait, Sound, 
IfWinNotActive, Sound, , WinActivate, Sound, 
WinWaitActive, Sound, 
Send, {ALTDOWN}{F4}{ALTUP}
ExitApp

The {DOWN 1} needs to be adjusted to the position of the mic in the recording devices list in the Sound control panel, as mine is in position 2, I'd change it to {DOWN 2}.

The uncommented "Send, {SHIFTDOWN}{TAB 4}{SHIFTUP}{HOME}{ENTER}" line is for enabling the device. The commented line below is to disable. You'll probably want to compile an exe for each function. (Enable.exe/disable.exe)

I hope it's useful to someone.

#2 TheDewd

TheDewd
  • Members
  • 823 posts

Posted 29 May 2012 - 04:01 PM

For the people running Windows XP:
SoundSet, 1, Microphone, mute  ; mute the microphone


#3 nascent

nascent
  • Members
  • 3 posts

Posted 29 May 2012 - 04:12 PM

For the people running Windows XP:

SoundSet, 1, Microphone, mute  ; mute the microphone



That's very different. That just mutes the mic, not disable it. The person I was scripting for specifically wanted a way to soft-disable the microphone.

Also from what I understand that only mutes the default microphone. The script I pasted disables the microphone device of your choice.

#4 sinkfaze

sinkfaze
  • Moderators
  • 6089 posts

Posted 29 May 2012 - 07:17 PM

Did you have a look at Lexikos' Vista Audio Control Functions?

#5 Guests

  • Guests

Posted 29 May 2012 - 07:45 PM

Thanks, no I wasn't aware of them. But I wanted as much backwards compatibility as possible. Also it was only an example project to help someone to achieve their goal. If it was to be a permanent tool I'd have opted for a real programming language.

I shall definitely bookmark the Lexikos stuff for future reference if a time ever comes.