February 20, 2023

Quickly Join Teams Meeting (using Outlook)

I share in this post how you can quickly join your next Teams Meeting using AutoHotkey or the Teams PowerTools. This implementation is based on Outlook Com integration.

Implementation Highlights

Find Next Meeting

Script is available in Outlook.ahk-> function Outlook_GetTeamsMeeting

The script will look for appointments in your Outlook Calendar for today's date using the Restrict method.

Outlook Com Restrict Work hours Weirdness

If you don't pass a time in the Restrict method, strangely Outlook will consider the day to start and end as defined in your work hours.

Restrict Count property issue

I thought at the beginning that the Restrict command wasn't working in AutoHotkey because the count property was not reflecting the number of Items found. This seems to be a known issue. In fact Restrict does work (only the Count value is bs.)

The script will then loop over the found appointments and check if it is a Teams meeting by parsing the appointment Body for a Teams meeting link (see below "Join" method).

The found meeting are then displayed for user selection in a ListBox (see screenshot below)

List Preselection

In the ListBox the appointment closest to current time will also be preselected. (See screenshot below)
For this feature I needed to use the DateParse function mentioned in the FormatTime Help. It was buggy so I had to include the PR.
Fixed version is available in my repo here.

Adaptive ListBox

I have tweaked a bit the ListBox function to properly size the heights/ number of rows. The ListBox function is available in my repo here.

Join Teams Meeting

Script is available in Outlook.ahk-> function Outlook_JoinTeamsMeeting

From the Appointment body you can parse for the Teams Meeting Link.
The RegExp used looks like:

If !RegExMatch(appt.Body,"<(https://teams.microsoft.com/l/meetup-join/[^>]*)>",teamslink)  
        Continue

Once you get the Teams meeting link, you can "simply" open it in the browser. 
Unfortunately, it will leave a browser window opened. Also in order not to be prompted to accept opening the link, I force using the Microsoft Edge browser. (I don't use Edge as default browser) The script does a clean-up i.e. automatically close the left-over window. 
So the "simple" teams meeting link opening looks at the end more complex as expected like this:

; Join meeting
RegExMatch(oItem.Body,"<(https://teams.microsoft.com/l/meetup-join/[^>]*)>",sMeetingLink)
If (sMeetingLink = "")
    return
sMeetingLink := sMeetingLink1
; Use microsoft edge because better integrated. Teams Links can be whitelisted (Application Links) to be always opened in Teams Client
Run, msedge.exe "%sMeetingLink%" " --new-window"
WinWaitActive, ahk_exe msedge.exe
NewEdgeWinId := WinExist("ahk_exe msedge.exe")

TeamsExe := Teams_GetExeName()
WinWaitActive, ahk_exe %TeamsExe%,,2
If ErrorLevel {
    TrayTipAutoHide("Error!","Joined Teams Meeting Window not found!",2000,3)
    return
}

JoinWinId := WinActive("A")

If WinExist("ahk_id " . NewEdgeWinId) {
    WinActivate
    Send ^w ; Close leftover browser window
}

Alternative solution using SendKeys

One could also use SendKeys to join a meeting from the meeting detailed view: pressing Alt or F10 will display then how to access the ribbon elements by keys:
The combination H then TJ will activate the Join Teams Meeting button.
But it isn't as nice as parsing the Body because you need to open the meeting item and send keys which might not be as robust. Moreover having the link url allows use to do more, like opening the chat in a separate browser window. (see "Pushing further")

Pushing Further

Now that we can Join a Meeting automatically, we can push a bit to automate how the meeting get joined and started.
First if we use always the same settings we might want to skip the Prejoin screen e.g. click on the Join button automatically.
Next, we might want also to unmute our microphone automatically: I have an Headset (Jabra Evolve2 65) that will mute the mic when the mic arm is up. I have encountered a lot of Teams meetings automatically muting me and I don't like having to use the Teams UI to unmute myself.

Also, I like to open the Meeting Chat in a separate window and put this Chat window to my secondary screen.
I also like to have the Meeting window maximized (I don't know why it isn't maximized by default when I join a meeting.)

Auto-join

; Click on join button
If (autoJoin) {
    UIA := UIA_Interface()
    TeamsEl := UIA.ElementFromHandle(JoinWinId)
   
    TeamsJoinBtn := TeamsEl.FindFirstBy("AutomationId=prejoin-join-button")

    If !TeamsJoinBtn {
        TrayTip, Join Teams Meeting! , "Join button not found!",,0x2
        return
    }
    TeamsJoinBtn.Click()  
    ; Wait for meeting window to open
    MuteEl:=TeamsEl.WaitElementExist("AutomationId=microphone-button",,,,2000)
    ; Unmute
    Name:=Teams_GetLangName("Unmute","Unmute")
    If (MuteEl.Name = %Name%)
        MuteEl.Click()
    ; Maximize
    WinMaximize, ahk_exe %TeamsExe%

}

Open Meeting Chat

To open the meeting chat in the browser, I simply transform the meeting url :

Teams_MeetingOpenChat(sMeetingLink){
; Open Meeting Chat in Web browser from Teams Meeting url
; Used for Quick Join+
;sLink := UrlDecode(sMeetingLink)
RegExMatch(sMeetingLink,"https://teams.microsoft.com/l/meetup-join/([^/]*)",sId)
sChatLink := "https://teams.microsoft.com/_#/conversations/" . sId1 . "?ctx=chat"
Run, %sChatLink%
; Open in new window
Browser_WinWaitActive()
WinId := Browser_WinExist()

; Send to second monitor
Monitor_MoveToSecondary(WinId)  
} ; eofun

PowerTools usage

With the Teamsy Launcher (included in TeamsShortcuts PowerTool) you can join your next Teams meeting using the keyword "jo" or "join".

To automatically join the meeting and using added join functionality (see section "Pushing further") you can use the keyword "jo+".



You can also access these functionalities via the TeamsShortcuts System Tray Icon menu under the Meeting submenu.

From the command line (e.g. for your Stream Deck integration) simply call Teams("jo") or Teamsy("jo+")
[This was wished by @CollabMoore]

See also

Teams Shortcuts - PowerTools

Teamsy with Deckboard (free Stream Deck on mobile) | Thierry Dalon's Blog

No comments:

Post a Comment