Last active
March 6, 2017 21:25
-
-
Save JoelBCarter/0480eb1c60c273f86cc1616be19c1de5 to your computer and use it in GitHub Desktop.
Quick way to mute Skype on Windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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