Last active
November 30, 2023 15:23
-
-
Save tdalon/5b3304559852d1d1942b7f1566de2a0c to your computer and use it in GitHub Desktop.
Get Microsoft Teams active Meeting Window with AutoHotkey
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Teams_GetMeetingWindow(Minimize:=false,showTrayTip:=true){ ; @fun_teams_getmeetingwindow@ | |
; Syntax: | |
; hWnd := Teams_GetMeetingWindow(Minimize:=true) | |
; If window is not found, hwnd is empty | |
; Input Arguments: | |
; Minimize: if true, minimized (aka Call in Progress) meeting window can be returned | |
; | |
; See implementation explanations here: | |
; https://tdalon.blogspot.com/2022/07/ahk-get-teams-meeting-win.html | |
; Does not require window to be activated | |
UIA := UIA_Interface() | |
TeamsExe := Teams_GetExeName() | |
WinGet, Win, List, ahk_exe %TeamsExe% | |
/* | |
If restoreWin | |
WinGet, curWinId, ID, A | |
*/ | |
Loop %Win% { | |
WinId := Win%A_Index% | |
; WinActivate, ahk_id %WinId% | |
TeamsEl := UIA.ElementFromHandle(WinId) | |
;MsgBox % TeamsEl.Name | |
If Teams_IsMeetingWindow(TeamsEl) { | |
If (!Minimize) | |
If Teams_IsMinMeetingWindow(TeamsEl) | |
Continue | |
return WinId | |
} | |
} ; End Loop | |
/* | |
If (restoreWin) | |
WinActivate, ahk_id %curWinId% ; restore win | |
*/ | |
If (showTrayTip) | |
TrayTip, Could not find Meeting Window! , No active Teams meeting window found!,,0x2 | |
} ; eofun | |
; ------------------------------------------------------------------------------------------------------------------- | |
Teams_IsMeetingWindow(TeamsEl,ExOnHold:=true){ | |
; does not return true on Share / Call in progress window | |
; If Meeting Reactions Submenus are opened AutomationId are not visible. | |
If (ExOnHold) { | |
Name := Teams_GetLangName("Resume","Resume") | |
If (Name="") | |
return | |
} | |
If TeamsEl.FindFirstBy("AutomationId=microphone-button") { | |
If (ExOnHold) { ; exclude On Hold meeting windows | |
If TeamsEl.FindFirstByName(Name) ; Exclude On-hold meetings with Resume button | |
return false | |
} | |
return true | |
} | |
return false | |
} ; eofun | |
; ------------------------------------------------------------------------------------------------------------------- | |
Teams_IsMinMeetingWindow(TeamsEl) { | |
; Return true if the window is a minimized meeting window | |
; Check for button "Navigate back" | |
Name := Teams_GetLangName("NavigateBack","Navigate back to call window.") | |
If InStr(Lang,"en-") or (Lang="") | |
Name := | |
If (Name="") | |
return | |
El := TeamsEl.FindFirstByNameAndType(Name, "button") ; | |
If El | |
return true | |
Else | |
return false | |
} ; eofun |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See explanation here https://tdalon.blogspot.com/2022/07/ahk-get-teams-meeting-win.html