In MS Teams new meeting experience the meeting it self always opens in a separate window, which I'd like to make active via apple script to be able to thereafter trigger a shortcut.

That way I can be in any other app and execute this for hotkey commands to work.

The meeting window title will always be unique as it uses the meeting title. Can we in just tell it to switch to the second window via applescript (regardless off title)?

Test Meeting


I only managed to use AXRaise and cycle through the windows, but I need to always raise it and select the second window in the list. Is there another way or do i need to click the menu item somehow and use arrow key down?

tell application "System Events"
    perform action "AXRaise" of window 2 of process "Microsoft Teams"
end tell

EDIT 2: just to be clear I need to target the same 2nd window each time (since the hotkey only work in the meeting window).

I also tried suggested solution below which does the same, cycling through the window, each time revealing the next one.

tell application "System Events"
    tell application process "Microsoft Teams"
        perform action "AXRaise" of window 2
        set frontmost to true
    end tell
end tell


tell application "System Events" to ¬
    perform action "AXRaise" of window 2 of ¬
        application process "Microsoft Teams"

tell application "Microsoft Teams" to activate

EDIT 3 - Solution

The Solution below works via UI but if there is another way without visually going through the dock menu that would be better, since once I executed it and are active in the window i no longer need to use it. (unless there is an if condition i can use to only trigger it if that window is not already active). I also found a better solution via app main menu see below.

However I'd still like to know if there is another/better way to specifically target a window i.e. second window of an app without using any menus.

  • What's wrong with Cmd/` [backtick] ? See Shortcut for toggling between different windows of same app?
    – Tetsujin
    Oct 13, 2021 at 15:35
  • I'm using a stream deck which buttons I want to configure to execute the app shortcut after the specific app window is active (so the shortcut works), no matter in what app I'm currently active in. Thus I need a solution ideally that programatically makes that second window active without visually showing/going through the dock icon menu selecting it.
    – Markus
    Oct 13, 2021 at 16:08
  • 1
    Just an FYI... The use of tell application "Microsoft Teams" in the code you just added is improper in that it is not needed and tell application "System Events" ... does not belong nested within another applications tell block. Also, solutions do not belong in the question section and should be posted as a separate answer. Oct 14, 2021 at 12:39
  • Wow thanks and for editing, much appreciated. Although you also removed my request for a better/alternative solution which is also still valid I think in case there is a way to switch without using the app's menu/dock menu. Or should I post that in a separate question?
    – Markus
    Oct 14, 2021 at 12:45
  • 1
    RE: "Although you also removed my request for a better/alternative solution ..." -- Sorry for that portion of the edit, I've put it back. Oct 14, 2021 at 13:20

2 Answers 2


I do not have Microsoft Teams, so I cannot test the example AppleScript code show below, however it works on the other applications I tested it on.

Based on the screenshot in the OP, assuming you want to actuate the menu of a Dock Tile and click a menu item, then here is a way to do it.

Example AppleScript code:

tell application "System Events"
    tell UI element "Microsoft Teams" of list 1 of application process "Dock"
        perform action "AXShowMenu"
        delay 0.1
        click menu item 2 of menu 1
    end tell
end tell


The example AppleScript code uses UI Scripting and can be kludgy and is dependent on allowing the script to complete before performing any other actions manually.

Note: The example AppleScript code is just that and sans any included error handling does not contain any additional error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay command may be necessary between events where appropriate, e.g. delay 0.5, with the value of the delay set appropriately.

  • Thanks, both unfortunately do the same as the code I posted, cycling through each window each time i execute it instead of targeting only the same 2nd window each time. When executing it once reveals the main MS Teams window and next time the meeting window etc. , back and forth. Unfortunately the hotkey only works in the meeting window.
    – Markus
    Oct 13, 2021 at 13:33
  • Brilliant thanks that worked, thought that this may be the only way, just didn't know how to for dock items, just menu bar, learned some cheers (for coming back with updated answer).
    – Markus
    Oct 13, 2021 at 14:08
  • I edited my post in case there is another way without visually going through the dock men, which would be better, since once I executed it and are active in the window i no longer need to use it for triggering the hotkey. Unless alternatively there is an if condition i can use to only trigger it if that window is not already active? Doubt that since that relies on targeting that 2nd window in the first place right? Or if I can set a variable or index so this can be checked the second time I execute it...?
    – Markus
    Oct 13, 2021 at 14:34
  • FYI I figured out a better solution that I added here using the app main menu. I'll leave your solution as accepted since you put in the effort and it works. My image in the OP was more for illustration rather than explicit solution, but glad we found two ways and one that works better, learned some.
    – Markus
    Oct 14, 2021 at 12:35


Since MS Teams lists the windows in the "Window" menu and it's always the last one in the list as far I know i managed to use the below which is much quicker and doesn't show any menu popups, sweet.

Adding the solution here as initially I didn't ask for a solution specific to the dock menu but rather how to trigger the second window of a running app and this solution is better.

EDIT: Turns out I also need set frontmost to true since the second window was successfully moved forward but the last active app staid still in front and prevented hotkeys to trigger in the second window.

enter image description here

tell application "System Events" to tell application process "Microsoft Teams"
    click (last menu item of menu 1 of menu bar item "Window" of menu bar 1)
    set frontmost to true
end tell

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .