Skip to content

Commit

Permalink
Quick Join move meeting window
Browse files Browse the repository at this point in the history
  • Loading branch information
Thierry Dalon committed Dec 19, 2023
1 parent 031572e commit 719ae8f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 44 deletions.
12 changes: 10 additions & 2 deletions Lib/Outlook.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,16 @@ If (autoJoin) {
If (MuteEl.Name = %Name%)
MuteEl.Click()
; Maximize
WinMaximize, ahk_exe %TeamsExe%

WinId := WinActive("ahk_exe %TeamsExe%")

; Move Meeting Window to secondary screen and maximize
SysGet, MonitorCount, MonitorCount ; or try: SysGet, var, 80
If (MonitorCount > 1) {
; Move to secondary monitor
Monitor_MoveToSecondary(WinId,false) ; bug: unshare on winactivate
Sleep 500 ; Wait for move to Maximize
} ; end if secondary monitor
WinMaximize, ahk_id %WinId%
}

; Open Meeting Chat in Web browser
Expand Down
79 changes: 37 additions & 42 deletions Lib/Teams.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -770,37 +770,39 @@ Teams_IsNew(){ ; @fun_teams_isnew@
; IsNew := Teams_IsNew()
; return true or false depending if Teams New Client is installed and Classic Teams running
static IsNew
If !(IsNew = "")
If !(IsNew = "") {
;MsgBox IsNew:%IsNew%
return IsNew
}

fExe = C:\Users\%A_UserName%\AppData\Local\Microsoft\WindowsApps\ms-teams.exe
If !(FileExist(fExe)) { ; New Teams not installed
IsNew := False
return IsNew
}

; Check if a Teams process is running
Process, Exist, Teams.exe
If (!ErrorLevel= 0) {
;Classic Teams
IsNew := False
return IsNew
}

Process, Exist, ms-teams.exe
If (!ErrorLevel= 0) {
If Not (ErrorLevel= 0) {
;Classic Teams
IsNew:=True
return IsNew
}

; Check if a Teams process is running ; need to disable Microsoft Teams classic in Startup to work at startup
Process, Exist, Teams.exe
If Not (ErrorLevel= 0) {
;Classic Teams
IsNew := False
return IsNew
}

; Possibility to overwrite in ini file if Teams is not started
If FileExist("PowerTools.ini") {
IniRead, IniIsNew, PowerTools.ini,Teams,TeamsIsNew
If !(IniIsNew="ERROR") {
IsNew := IniIsNew
return IsNew
}

}
IsNew:=True
return IsNew
Expand All @@ -820,24 +822,23 @@ Teams_GetExe() {
}

Teams_RunExe(){
If Teams_IsNew() {
; New Teams in WindowsApp C:\Users\%A_UserName%\AppData\Local\Microsoft\WindowsApps
fExe := "ms-teams.exe"
Run, %fExe%
} Else { ; Classic Team Client
;fExe = C:\Users\%A_UserName%\AppData\Local\Microsoft\Teams\current\Teams.exe
;fExe = C:\Users\%A_UserName%\AppData\Local\Microsoft\Teams\Update.exe --processStart "Teams.exe"
Run, "C:\Users\%A_UserName%\AppData\Local\Microsoft\Teams\Update.exe" --processStart "Teams.exe"
}

If Teams_IsNew() {
; New Teams in WindowsApp C:\Users\%A_UserName%\AppData\Local\Microsoft\WindowsApps
fExe := "ms-teams.exe"
Run, %fExe%
} Else { ; Classic Team Client
;fExe = C:\Users\%A_UserName%\AppData\Local\Microsoft\Teams\current\Teams.exe
;fExe = C:\Users\%A_UserName%\AppData\Local\Microsoft\Teams\Update.exe --processStart "Teams.exe"
Run, "C:\Users\%A_UserName%\AppData\Local\Microsoft\Teams\Update.exe" --processStart "Teams.exe"
}
} ;eofun
; ----------------------------------------------------------------------
; ----------------------------------------------------------------------
Teams_GetExeName(){
If Teams_IsNew()
return "ms-teams.exe"
Else
return "Teams.exe"
Teams_GetExeName(IsNew:=""){
If Teams_IsNew()
return "ms-teams.exe"
Else
return "Teams.exe"
} ;eofun
; ----------------------------------------------------------------------

Expand All @@ -849,7 +850,6 @@ Teams_SharingControlBar(mode:="-") {
return
}


Lang := Teams_GetLang()
Prop := "SharingControlBar"
Name := Teams_GetLangName(Prop,"Sharing control bar",Lang)
Expand Down Expand Up @@ -2001,18 +2001,19 @@ SendInput +{enter}

; -------------------------------------------------------------------------------------------------------------------
Teams_GetMeetingWindow(Minimize:=false,showTrayTip:=true){ ; @fun_teams_getmeetingwindow@
; Get active Teams Meeting window
; Syntax:
; hWnd := Teams_GetMeetingWindow(Minimize:=true)
; hWnd := Teams_GetMeetingWindow(Minimize:=false,showTrayTip:=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
Expand Down Expand Up @@ -2042,12 +2043,10 @@ If (showTrayTip)
; -------------------------------------------------------------------------------------------------------------------

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.

; Check if UIA Window is an active* meeting window
; By default exclude On-hold meetings (with Resume button)
If (ExOnHold) {
Name := Teams_GetLangName("Resume","Resume")
Name := Teams_GetLangName("Resume","Resume")
If (Name="")
return
}
Expand All @@ -2067,13 +2066,9 @@ 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
Expand All @@ -2092,10 +2087,10 @@ Teams_ActivateMainWindow(){

; -------------------------------------------------------------------------------------------------------------------
Teams_ActivateMeetingWindow(){
; WinId := Teams_ActivateMainWindow()
WinId:= Teams_GetMeetingWindow()
WinActivate, ahk_id %WinId%
return WinId
; WinId := Teams_ActivateMainWindow()
WinId:= Teams_GetMeetingWindow()
WinActivate, ahk_id %WinId%
return WinId
} ; eofun

; -------------------------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 719ae8f

Please sign in to comment.