(view source code of togglemicrophonemute.cs as plain text)
using System;
using System.Runtime.InteropServices;
namespace RobvanderWoude{internal class ToggleMicrophoneMute
{static readonly string progver = "1.00";
static int Main( string[] args )
{if ( args.Length == 0 )
{AudioControl.ToggleMicrophoneMute( );
return 0;
} else {Console.Error.WriteLine( "ToggleMicrophoneMute.exe, " + progver );
Console.Error.WriteLine( "Toggle the microphone's muted state" );
Console.Error.WriteLine( );
Console.Error.Write( "Usage: " );
Console.ForegroundColor = ConsoleColor.White;
Console.Error.WriteLine( "ToggleMicrophoneMute" );
Console.ResetColor( );
Console.Error.WriteLine( );
Console.Error.WriteLine( "Notes: This program is a wrapper for C++ code by Io-oI" );
Console.Error.Write( " on " );
Console.ForegroundColor = ConsoleColor.DarkGray;
Console.Error.WriteLine( "https://superuser.com/a/1870763" );
Console.ResetColor( );
Console.Error.WriteLine( " No guarantee: if no microphone is available," );
Console.Error.WriteLine( " or if it is locked by another program, the" );
Console.Error.WriteLine( " (un)mute command is ignored without notification." );
Console.Error.WriteLine( " Return code equals -1 if any command line" );
Console.Error.WriteLine( " arguments were specified, or 0 otherwise." );
Console.Error.WriteLine( );
Console.Error.WriteLine( "Written by Rob van der Woude" );
Console.Error.WriteLine( "https://www.robvanderwoude.com" );
return -1;
} } } // code by Io-oI // https://superuser.com/a/1870763public class AudioControl
{[DllImport( "user32.dll", CharSet = CharSet.Auto )]
public static extern int SendMessage( int hWnd, int Msg, int wParam, int lParam );
public const int WM_APPCOMMAND = 0x319;
public const int APPCOMMAND_MICROPHONE_VOLUME_MUTE = 0x180000;
public static void ToggleMicrophoneMute( )
{SendMessage( 0xFFFF, WM_APPCOMMAND, 0, APPCOMMAND_MICROPHONE_VOLUME_MUTE );
} }}page last modified: 2025-10-11; loaded in 0.0082 seconds