微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何使用 AutoHotkey 获取 Microsoft Teams 活动会议窗口?

如何解决如何使用 AutoHotkey 获取 Microsoft Teams 活动会议窗口?

在 Microsoft Teams Windows 客户端中,我希望能够使用 AutoHotkey 识别当前活动的会议窗口。 考虑到您可以打开多个 Teams 窗口(弹出的聊天窗口、主窗口、几个会议窗口,其中一些窗口处于暂停状态,...)

(背景:我想这样做是为了能够发送会议特定的操作热键。)

解决方法

我找到了另一种基于 FindText 的方法来排除任何用户提示。 如果像 Leave 和 Resume 这样的 UI 元素可用于 100% 排除错误的窗口,它会检查 Teams 窗口。

请参阅此帖子中的详细说明:https://tdalon.blogspot.com/2021/04/ahk-get-teams-meeting-window.html 与截屏。 这里是要点中的代码:https://gist.github.com/tdalon/d376a2ac395a41c5453904222cbcb529

摘录如下:

Teams_GetMeetingWindow(useFindText:="",restore := True){
; See implementation explanations here: 
;   https://tdalon.blogspot.com/2021/04/ahk-get-teams-meeting-window.html
;   https://tdalon.blogspot.com/2020/10/get-teams-window-ahk.html

If (useFindText="")
    useFindText := PowerTools_GetParam("TeamsMeetingWinUseFindText") ; Default 1

If (useFindText) {
    If (restore)
        WinGet,curWinId,ID,A
    ResumeText:="|<>*138$51.zzzzzzzzw3zzzzzzzUDzzzzzzwtzzzzzzzbA64NU1kQ1423A04FUtUQNa8aAX0EXAlY1a9zUNaAbwt4Y0AlYHb4461aAkTzzzzzzzzU" ; FindText for Resume
    LeaveText:="|<>*168$66.zzzzzzzzzzzzzzzzDzzzzzy01zzDzzzzzs00TzDzzzzzk00DzDkkFW3U7k7zDUG9YFUDk7zD6T9YlUTs7zD0E841kTs7zD7nAAzszwDz022AAHzzzzz0UECS3zzzzzzzzzzzU"
}

WinGet,Win,List,ahk_exe Teams.exe
TeamsMainWinId := Teams_GetMainWindow()
TeamsMeetingWinId := PowerTools_RegRead("TeamsMeetingWinId")
WinCount := 0
Select := 0


Loop %Win% {
    WinId := Win%A_Index%
    If (WinId = TeamsMainWinId) { ; Exclude Main Teams Window 
        ;WinGetTitle,Title,% "ahk_id " WinId
        ;MsgBox %Title%
        Continue
    }
    WinGetTitle,% "ahk_id " WinId  
    
    IfEqual,Continue
    Title := StrReplace(Title," | Microsoft Teams","")
    If RegExMatch(Title,"^[^\s]*\s?[^\s]*,[^\s]*\s?[^\s]*$") or RegExMatch(Title,[^\s]*\s?[^\s]*\([^\s\(\)]*\)$") ; Exclude windows with,in the title (Popped-out 1-1 chat) and max two words before,Name,Firstname               
        Continue
    
    If RegExMatch(Title,"^Microsoft Teams Call in progress*") or RegExMatch(Title,"^Microsoft Teams Notification*") or RegExMatch(Title,"^Screen sharing toolbar*")
        Continue
    
    If (useFindText) {
        ; Exclude window with no Leave element
        WinActivate,ahk_id %WinId%
        If !(ok:=FindText(,LeaveText,0)) {
            Continue
        } 
        
        ; Final check - exclude window with Resume element = On hold meetings
        If (ok:=FindText(,ResumeText,0)) {
            Continue
        } 
    }
        
    WinList .= ( (WinList<>"") ? "|" : "" ) Title "  {" WinId "}"
    WinCount++

    ; Select by default last meeting window used
    If WinId = %TeamsMeetingWinId% 
        Select := WinCount  
} ; End Loop

If (WinCount = 0)
    return
If (WinCount = 1) { ; only one other window
    RegExMatch(WinList,"\{([^}]*)\}$",WinId)
    TeamsMeetingWinId := WinId1
    PowerTools_RegWrite("TeamsMeetingWinId",TeamsMeetingWinId)
    return TeamsMeetingWinId
}

If (restore)
    WinActivate,ahk_id %curWinId%

LB := WinListBox("Teams: Meeting Window","Select your current Teams Meeting Window:",WinList,Select)
RegExMatch(LB,WinId)
TeamsMeetingWinId := WinId1
PowerTools_RegWrite("TeamsMeetingWinId",TeamsMeetingWinId)
return TeamsMeetingWinId

} ; eofun
,

我试图通过窗口标题找到它,但 Teams 没有以特定方式命名会议窗口。

我可以通过 AccViewer 发现主团队窗口的名称以“| Microsoft Teams,主窗口”结尾。所以至少我可以排除这个。

Here 是我想到的最佳解决方案。 但需要用户确认当前会议窗口是哪个窗口(如果不明显)。

代码可以在这个 Gist 中找到:https://gist.github.com/tdalon/87590637e43479c90f355be90aff3842#file-teams_getmeetingwindow-ahk

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。