Keyboard shortcut to mute Teams with AutoHotKey

  • Post category:IT
  • Post comments:7 Comments

Edit (16/01/2021): I have found a small utility that does exactly what I needed: MicMute. It is a simple keyboard hook that will mute/unmute the mic, with a method that is compatible with Microsoft Teams. You still must be careful when using it because you cannot mix the use of MicMute and the mute button of Teams, and be careful to let both in sync (be careful especially to Teams auto-mute function when entering a room with more than 5 people). If any problem, check the level of your microphone in the microphone device options; it may have been altered. Even it is a little off-topic of this post, I think this can be useful, and as the source code is available, the mute method could be converted to AutoHotKey.

Edit (14/12/2020): Randy has shared in the comments a version working with Teams version 1.3.00.30866 (direct link)

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 7 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.

  4. Randy

    The various scripts here didn’t work for me on the most recent versions of Teams, but it did help me create a script that does work. My script doesnt address the issue of multiple simultaneous calls, but I don’t personally have that requrirement. Recent versions of teams potentially uses multiple windows, including the main Teams window, the meeting window, a notification window and a separate screen sharing window. The shortcut needs to select the appropriate Teams window to send the shortcut to. The keyboard shortcut can be sent to either the main window or the meeting window, but it has to ignore the notification and screen sharing windows. Here is my script:

    AppsKey::
    WinGet, id, list, ahk_exe Teams.exe ;get IDs for all teams windows
    Loop, %id% ;Loop through IDs of all teams windows
    {
    this_ID := id%A_Index%
    WinGetTitle, Title, ahk_id %this_ID% ;get the title of the current window
    If Title Microsoft Teams Notification ;make sure title is not the notification
    {
    If Title ;screen sharing win uses null title, make sure the win does not have a null title
    {
    WinActivate, ahk_id %this_ID% ;This should be the correct win, activate it

    The script is better formatted at: https://www.autohotkey.com/boards/viewtopic.php?f=6&t=84286&p=369546#p369546

    1. Rémi Peyronnet

      Thanks for sharing. I updated the article to refer your script. I hope future versions of Teams will stop breaking the scripts 😉

  5. R

    Awesome script, thanks!!

Leave a Reply

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