Last active
November 3, 2023 13:43
-
-
Save tdalon/234d5bdcc425b1e0d9508b4b722c98db to your computer and use it in GitHub Desktop.
Teams Mute 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_Mute(State := 2,showInfo:=true,restoreWin:=true){ | |
; State: | |
; 0: mute off, unmute | |
; 1: mute on | |
; 2*: (Default): Toggle mute state | |
WinId := Teams_GetMeetingWindow() | |
If !WinId ; empty | |
return | |
If (restoreWin) | |
WinGet, curWinId, ID, A | |
If (showInfo) { | |
displayTime := 2000 | |
Tray_Icon_On := "HBITMAP:*" . Create_Mic_On_ico() | |
Tray_Icon_Off := "HBITMAP:*" . Create_Mic_Off_ico() | |
} | |
UIA := UIA_Interface() | |
TeamsEl := UIA.ElementFromHandle(WinId) | |
Lang := Teams_GetLang() | |
MuteName := Teams_GetLangName("Mute",Lang) | |
If (MuteName="") { | |
If !InStr(Lang,"en-") { | |
Text := "Language " . Lang . " not implemented!" | |
sUrl := Teamsy_Help("lang",false) | |
PowerTools_ErrDlg(Text,sUrl:="") | |
} | |
MuteName := "Mute" | |
UnmuteName := "Unmute" | |
} | |
If (UnmuteName ="") { | |
UnmuteName := Teams_GetLangName("Unmute",Lang) | |
} | |
El:=TeamsEl.FindFirstBy("AutomationId=microphone-button") | |
If RegExMatch(El.Name,"^" . MuteName) { | |
If (State = 0) { | |
If (showInfo) | |
Tooltip("Teams Mic is already on.") | |
return | |
} Else { | |
If (showInfo) { | |
Tooltip("Teams Mute Mic...",displayTime) | |
TrayIcon_Mic_Off := "HBITMAP:*" . Create_Mic_Off_ico() | |
TrayIcon(TrayIcon_Mic_Off,displayTime) | |
} | |
El.Click() ; activates the window | |
If (restoreWin) | |
WinActivate, ahk_id %curWinId% | |
return | |
} | |
} | |
If RegExMatch(El.Name,"^" . UnmuteName) { | |
If (State = 1) { | |
If (showTooltip) | |
Tooltip("Teams Mic is already off.") | |
return | |
} Else { | |
If (showInfo) { | |
Tooltip("Teams Unmute Mic...",displayTime) | |
TrayIcon_Mic_On := "HBITMAP:*" . Create_Mic_On_ico() | |
TrayIcon(TrayIcon_Mic_On,displayTime) | |
} | |
El.Click() | |
If (restoreWin) | |
WinActivate, ahk_id %curWinId% | |
return | |
} | |
} | |
} ; eofun |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See details https://tdalon.blogspot.com/2021/04/teams-shortcuts-mute-on-off.html