Skip to content

Instantly share code, notes, and snippets.

@JoelBCarter
Last active March 6, 2017 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoelBCarter/0480eb1c60c273f86cc1616be19c1de5 to your computer and use it in GitHub Desktop.
Save JoelBCarter/0480eb1c60c273f86cc1616be19c1de5 to your computer and use it in GitHub Desktop.
Quick way to mute Skype on Windows
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class Tricks {
[DllImport("user32.dll")]
public static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetForegroundWindow(IntPtr hWnd);
}
"@
$wshell = New-Object -ComObject wscript.shell;
# Get currently selected window
$currentWindowHandle = [tricks]::GetForegroundWindow();
$currentWindowProcess = get-process | ? { $_.mainwindowhandle -eq $currentWindowHandle }
# Get Skype
if($wshell.AppActivate('Skype')){
# Sleep 1; # Might need this ...
$wshell.SendKeys("^{m}"); # Send mute chord (CTRL + M)
$wshell.AppActivate($currentWindowProcess.MainWindowTitle); # Restore previous window
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment