Skip to content

Instantly share code, notes, and snippets.

@enyone
Created October 12, 2025 19:48
Show Gist options
  • Select an option

  • Save enyone/d0e3ce523e0b693b6c00be5554a7cfd7 to your computer and use it in GitHub Desktop.

Select an option

Save enyone/d0e3ce523e0b693b6c00be5554a7cfd7 to your computer and use it in GitHub Desktop.
Windows microphone mute toggle scripts
$source = @"
[DllImport("user32.dll")] public static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")] public static extern IntPtr SendMessageW(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
private const int WM_APPCOMMAND=0x319;
private const int APPCOMMAND_MICROPHONE_VOLUME_MUTE=0x180000;
public static void MicMute(IntPtr h) {
SendMessageW(h, WM_APPCOMMAND, h, (IntPtr)APPCOMMAND_MICROPHONE_VOLUME_MUTE);
}
"@
add-type -name CSharp -member $source -namespace Local;
[Local.CSharp]::MicMute([Local.CSharp]::GetForegroundWindow());
@enyone
Copy link
Author

enyone commented Oct 12, 2025

Companion helper script MicMute.js

WScript.CreateObject("Shell.Application").ShellExecute(
  "powershell.exe",
  "-File MicMute.ps1",
  "",
  "",
  0
);

Run with

> wscript.exe /e:JScript MicMute.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment