Make Microsoft Teams shortcuts global

I live for keyboard shortcuts.

Microsoft Teams has plenty of useful keyboard shortcuts, but if you’re running a complex meeting and maybe using OBS Studio like I did recently, they’re probably not going to work. Why’s that? They’re not ‘global’ – they’ll only work when the Teams client has the focus.

The fix is relatively simple, disguised as the open-source utility AutoHotkey, or AHK.

AHK Features

“AutoHotkey is a free, open-source custom scripting language for Microsoft Windows, initially aimed at providing easy keyboard shortcuts or hotkeys, fast macro-creation and software automation that allows users of most levels of computer skill to automate repetitive tasks in any Windows application.” – Wikipedia.

Here are just SOME of AHK’s features:

  • Automatic text replacement (e.g. type ‘bbs’ and it will delete ‘bbs’ and replace it with ‘be back soon’).
  • Automating repetitive tasks like filling out web forms.
  • Inserting signatures or other frequently used blocks of text.
  • Correcting your frequently mis-typed words.

Of particular interest to us in this powerful utility is its ability to query all the running programs – AND CHANGE FOCUS!

So if Microsoft Teams doesn’t have the focus, AHK is able to change focus BACK to it, inject its (local) shortcut, then change back to whatever was “on top” (focussed) beforehand.

All this power in a simple script file

All your customisations live in a text file with a “.ahk” extension, the contents written in a relatively straightforward scripting language.

The below AHK script does three things:
– Control-Shift-Alt-M switches to your active Teams *meeting*, toggles the Mute, then returns focus to the original app.
– Control-Shift-Alt-N switches to your active PowerPoint presentation, advances the slide & returns to wherever previously had focus.
– Control-Shift-Alt-P switches to your active PowerPoint presentation, goes back a slide & returns.

Note that anything after a semi-colon is ignored as it’s a comment, code steps inside braces are grouped together, and the keyboard triggers precede two colons.

In the sample below, “+^!M::” triggers the action that follows it if you type shift (“+”), control (“^”), alt (“!”) and an M. Execution of the sequence ends when it hits a ‘return’.

There’s lots more in the online forum, and the local helpfile. See the References further down for more info.

SetTitleMatchMode, 2 ; 2 = a partial match on the title

WinGet, winid, ID, A	; Save the current window ID
if WinExist("(Meeting)") ;Yes, every Teams meeting has that in the title bar - even if it's not visible to you
	WinActivate ; Without any parameters this activates the previously retrieved window - in this case your meeting
	Send, ^+M   ; Teams' native Mute shortcut
        WinActivate ahk_id %winid% ; Restore previous window focus

; POWERPOINT - Next slide
WinGet, winid, ID, A
if WinExist("PowerPoint Slide Show") ;This works if you're using Presenter View too
	Send, N
        WinActivate ahk_id %winid%

; POWERPOINT - Previous slide
WinGet, winid, ID, A
if WinExist("PowerPoint Slide Show")
	Send, P
        WinActivate ahk_id %winid%

Of course the choice of shortcuts is yours, and they can become your new de-facto replacements. They always work, even if Teams or PowerPoint already has the focus.

If you have a Stream Deck then it doesn’t matter how complicated you make them, because they’re only a quick tap away regardless.

Add to Stream Deck

Finger twisting shortcut key combinations are no fun though. That’s where the Stream Deck (Amazon US / JBHifi – AU) comes in.

The physical models in the Stream Deck family are USB-powered mini-keyboards, and behind each each context-sensitive button is a customisable LCD screen. (I wrote some more about them in my last post.)

Here’s the setup screen showing the key layout, that each button is configured as a “Hotkey”, and the icons I’ve created for it.

(BTW, Stream Deck has a nifty online icon generator to make this process easy too, although in this case I’ll admit to creating the images in Snagit first, then importing them into the icon generator for the final sizing steps.)

Here’s the final product:

Setting up AHK

I skipped this bit earlier because I wanted to show how easy it was to get to the outcome, but the steps to install and having AHK auto-run couldn’t be much simpler:

  1. Download and run the installer.
  2. When prompted, choose “Express Installation” (unless you want to change the install path, etc).
  3. When you see the “installation complete” menu, click “Exit”.
  4. Create the .ahk script file as shown above.
  5. Create a shortcut to the file.
  6. Open your startup folder: click Start, then type Run and hit return.
  7. Type “shell:startup” (without the quotes) and hit return.
  8. Copy the shortcut to this folder.
  9. Double-click on the script file to run it.
  10. Done!


Obviously this trickery can work for a lot more than Microsoft Teams and PowerPoint. Let your imagination run wild.

Should you be in an environment where you don’t have Admin rights, there’s a way around that too. ;-)

If you make any changes to the script, right-click the green “H” icon in the tray and choose “Reload This Script”. (You’ll see there’s a handy Edit shortcut there too.) If you’ve made a whoops in your edit, a popup will even point out the offending line number.

If you want to experiment some more with switching apps, right-click on the tray icon again and choose “Window Spy”. This launches a popup that reveals the executable name of the focussed app, its title bar (even if hidden), and a lot more useful information.


Revision History

30th June 2020. This is the initial publication.

Thanks as always to Rocky for the awesome photo.

– G.


    • Easy peasy!

      Just add this into your ahk file:

      ; Turn Return into Shift+Return
      #IfWinActive ahk_exe Teams.exe

      EDIT: Whoops. I spoke too soon. Whilst it does what it’s meant to in Teams, it’s also firing on (all?) other apps. Let me get back to you.
      EDIT2: There you go. I think that’s fixed it.

      – Greig.

  1. You can send keys to an application without switching to it and back by using ControlSend.

    However, it now looks like Teams does not include (Meeting) in meeting window title bars, which makes it difficult to match.

  2. Hi, I had to alter your code as follows. Window was not found by “(meeting)” string. But general “Microsoft Teams” worked. Slight wait was needed, Teams didn’t observe the keypress otherwise.

    SetTitleMatchMode, 2 ; 2 = a partial match on the title

    WinGet, winid, ID, A ; Save the current window ID
    if WinExist("Microsoft Teams") ; Every Teams window has this in title, it doesn't matter which is chosen
    WinActivate ; Without any parameters this activates the previously retrieved window = any MS Teams window
    Sleep, 10 ; wait a bit
    Send ^+m ; Teams' native Mute shortcut
    Sleep, 10 ; wait a bit
    WinActivate ahk_id %winid% ; Restore previous window focus

  3. Hello, I had to elaborate a bit more, because this won’t work if you have multiple teams window.

    ; MICROSOFT TEAMS – Toggle Mute
    WinGet, winid, ID, A ; Save the current window ID
    WinGet windows, List
    Loop %windows%
    id := windows%A_Index%
    WinGetTitle wt, ahk_id %id%
    src := “Microsoft Teams”
    ifInString, wt, %src%
    WinActivate ahk_id %id% ; Activate Teams window
    Send ^+m ; Teams’ native Mute shortcut
    WinActivate ahk_id %winid% ; Restore previous window focus

    • Still, I was somehow dissatisfied, and found this solution on ahk forums that works perfectly, so I can mute my microphone at the system level and not only for microsoft teams:

      What I love about this is the little tooltip on the mouse that shows the current state of the mute, and the possibility to split the command into two separate On/Off buttons instead of a single toggle, so that I don’t have to remember constantly the current mute status.

Leave a Reply

Your email address will not be published. Required fields are marked *

... and please just confirm for me that you're not a bot first: Time limit is exhausted. Please reload the CAPTCHA.

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