Keyboard shortcut to mute Teams with AutoHotKey

  • Post category:IT
  • Post comments:4 Comments

With the confinement because of COVID-19, I have been using Microsoft Teams for my work with my home setup that does not have a “mute” button to mute the mic of Microsoft Teams. And that’s is very annoying as Microsoft had the very odd idea to set the mute keyboard shortcut to “Ctrl+Maj+M”, which is not handy at all to operate! And it is not possible to change it.

Here is an AutoHotKey script to replace it by the hotkey  Left Control + Left Alt (please note the Left Control key must be pressed before Left Alt). This version works for Teams without the new feature with meeting windows detached from the main window (see at the end).

You may also download the compiled version: mute-teams.zip

This tool is great, very simple to use, even it is surprising at first: you write a script ahk with AutoHotKey syntax and execute it with one of the provided binaries. The script will remain visible in the tray bar so it can be stopped. You can also compile the script with the provided compiler, and get a standalone executable you can distribute without any annoying dependencies. And there is a ton of much more advanced features that I used to create GUIs, tray bar menu, etc.

I have struggled a while with the use of ControlSendthat should be able to send keys to a window without the need to be focused, but it worked sometimes… or not… That is why this version activates shortly the target window and revert to the one you were using. A discreet beep indicates the hotkey has been fired.

Do not miss SciTE4AutoHotKey: in addition to syntax highlighting it will provide a quite efficient debugging environment.

The new Teams feature that open distinct windows for each call/conversation breaks this script, and there is no simple way to identify the right window to mute. As a workaround, below is a script that will loop each Teams window, and focus and send Ctrl+Shit+M to each :

If you use Teams to have multiple calls simultaneously the script above might not behave as you like. Ben S. has provided in the comments below the article another version based on the window size that may better suit you.

This Post Has 4 Comments

  1. wookash

    how do you identify the meeting window with the new feature, where meeting window is detached from teams app in a separate window. I struggle with this script working when I have a separate window for chat, main teams app and the meeting window

  2. Rémi Peyronnet

    That is quite a problem for this script because I found nothing to get the meeting window that is using the mic (same process name, same class name,…). As a workaround, I modified the script to loop through each Teams window and send Ctrl+Shit+M to each window. I modified the article to add the new version.
    Besides that I like this new feature 🙂

  3. Ben S.

    I like this concept but I have a question. If it toggles mute in all windows might it unmute one and mute another? I’m not sure if Teams allows joining multiple calls at once like Skype for Business does.

    I just wrote a script like this to open the main Teams window. There isn’t a good way to which one is the main window but I’m going to assume that the small windows are popout chat and the main window will be bigger.

    ; Note that if you want to differentiate between the main Teams window and a popup chat,
    ; check the active window position *width*. A popup chat window will usually not be very wide (in my typical usage)
    ; Minimum size of popout chat is 602×500.
    ; Minimum size of main window is 720×500.

    ; Activating a window by size (and class/exe match)
    WinGet, id, list, ahk_exe Teams.exe
    Loop, %id%
    {
    this_ID := id%A_Index%
    WinGetPos,,, Width, Height, ahk_id %this_ID%
    If (Width>=720 and Height>=500)
    {
    WinActivate, ahk_id %this_ID%
    break
    }
    }

    1. Rémi Peyronnet

      Thanks for sharing. I guess this would depend on each one usage so I modified the article to mention your alternative.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.