Dedicated Microsoft Teams mute toggle keyboard shortcut

Post your working scripts, libraries and tools for AHK v1.1 and older
TheRandy
Posts: 1
Joined: 10 Dec 2020, 21:41

Dedicated Microsoft Teams mute toggle keyboard shortcut

10 Dec 2020, 21:51

I used AHK to create a dedicated Microsoft Teams mute toggle keyboard shortcut for my apps/menu key, but you can obviously modify the key to use any keyboard shortcut. It's not as straightforward as it seems because recent versions of teams potentially uses multiple windows, including the main Teams window, the meeting window, a notification window and a separate screen sharing window. The shortcut needs to select the appropriate Teams window to send the shortcut to. The keyboard shortcut can be sent to either the main window or the meeting window, but it has to ignore the notification and screen sharing windows.

It's currently working in Teams version 1.3.00.30866

Code: Select all

AppsKey::
WinGet, id, list, ahk_exe Teams.exe			;get IDs for all teams windows
Loop, %id% 							;Loop through IDs of all teams windows
{
this_ID := id%A_Index%
WinGetTitle, Title, ahk_id %this_ID%			;get the title of the current window
If Title <> Microsoft Teams Notification		;make sure title is not the notification
{
If Title <> 								;screen sharing win uses null title, make sure the win does not have a null title
{
WinActivate, ahk_id %this_ID%				;This should be the correct win, activate it
Send, ^M								;send ctrl,shift,m shortcut
break								;There are two teams windows, the main win and the meeting win, break the loop so that the mute commmand doesnt get sent twice
}
}
}

This post helped me put this script together: https www.lprp.fr /2020/03/keyboard-shortcut-to-mute-teams-with-autohotkey/ Broken Link for safety
aweinberg
Posts: 52
Joined: 08 Feb 2019, 15:38

Re: Dedicated Microsoft Teams mute toggle keyboard shortcut

14 Dec 2020, 17:14

Works for me, thanks for sharing!
User avatar
tdalon
Posts: 44
Joined: 21 Apr 2017, 07:19
Location: Germany
Contact:

Re: Dedicated Microsoft Teams mute toggle keyboard shortcut

27 Jan 2021, 08:54

See here for a library of Teams functions: https://github.com/tdalon/ahk/blob/master/Lib/Teams.ahk
Specially Teams_Mute() and Teams_GetMeetingWindow() (documentation here: https://tdalon.blogspot.com/2020/10/get-teams-window-ahk.html)
Your script here is not robust enough now that we can have multiple windows in Teams e.g. popped-out chat window and multiple meeting windows (on hold)
I like to run the Teams Mute feature from Teamsy https://tdalon.github.io/ahk/Teamsy via Executor.
mattyoh
Posts: 1
Joined: 27 Jan 2021, 06:26

Re: Dedicated Microsoft Teams mute toggle keyboard shortcut

28 Jan 2021, 04:54

This script works perfectly for me. Thank you!
Or rather for my wife now teaching online from home! Having seen her use Teams, little enhancements like this script are invaluable.
Programming a mouse button to activate the script works well for her but with this I noticed that while using Teams she is often now focussed on a different application eg Powerpoint or a Whiteboard so does not easily see the tiny 'mic' icon in Teams to ascertain if she is muted/unmuted. To help with this I added a simple
SoundPlay, %windir%\sound.wav
line to the script which is a great little audible confirmation the script has run, however, it still doesn't confirm whether muted or unmuted.

My question is this... is there a way for AHK to tell which state, muted or unmuted, Teams is currently in and then to use this info to play an appropriate audio file to indicate which.
Better still, would it be possible to create an on screen overlay over all other apps to indicate whether muted or not.

If anyone knows if or how this could be done or point me in the right direction, I would be very grateful.
User avatar
tdalon
Posts: 44
Joined: 21 Apr 2017, 07:19
Location: Germany
Contact:

Re: Dedicated Microsoft Teams mute toggle keyboard shortcut

10 Apr 2021, 03:46

Last edited by tdalon on 30 Jan 2023, 15:10, edited 1 time in total.
Cooper_da
Posts: 3
Joined: 20 Jan 2023, 09:41

Re: Dedicated Microsoft Teams mute toggle keyboard shortcut

20 Jan 2023, 09:48

Hi,

sorry for bringing this old thread back to life.

I am using this script for a while and it works well. Lately I noticed that the script cannot be executed while notification popups are shown. Any ideas for a workaround?

Using the mouse in this situation is a hassle and waiting for the popup can take a while if several messages come in.

thanks.
User avatar
tdalon
Posts: 44
Joined: 21 Apr 2017, 07:19
Location: Germany
Contact:

Re: Dedicated Microsoft Teams mute toggle keyboard shortcut

30 Jan 2023, 15:06

Cooper_da wrote:
20 Jan 2023, 09:48
Hi,

sorry for bringing this old thread back to life.

I am using this script for a while and it works well. Lately I noticed that the script cannot be executed while notification popups are shown. Any ideas for a workaround?

Using the mouse in this situation is a hassle and waiting for the popup can take a while if several messages come in.

thanks.
I've stumbled upon this question really by chance (no notification). Please post an issue on the GitHub repo and describe it well so I can reproduce it.
beand1p
Posts: 1
Joined: 08 Jan 2021, 15:23

Re: Dedicated Microsoft Teams mute toggle keyboard shortcut

18 Oct 2023, 08:03

The script below no longer appears to be working for the new Teams client: https://techcommunity.microsoft.com/t5/microsoft-teams-blog/announcing-general-availability-of-the-new-microsoft-teams-app/ba-p/3934603. I have also tried changing Teams.exe to ms-teams.exe which is what AutoHotkey Window Spy reports, but that does not fix. Anyone have any ideas?

Code: Select all

Pause::
; Get IDs for all teams windows
WinGet, id, list, ahk_exe Teams.exe		

; Loop through IDs of all teams windows
Loop, %id% 
{
	this_ID := id%A_Index%

	; Get the title of the current window
	WinGetTitle, Title, ahk_id %this_ID%
	
	; Make sure title is not the notification
	if Title <> Microsoft Teams Notification	
	{
		; Screen sharing win uses null title, make sure the win does not have a null title
		if Title <>
		{
			; This should be the correct win, activate it
			WinActivate, ahk_id %this_ID%

			; Send Ctrl Shift M shortcut
			Send, ^M

			; There are two teams windows, the main win and the meeting win, break the loop so that the mute commmand doesnt get sent twice
			break
		}
	}
}
User avatar
tdalon
Posts: 44
Joined: 21 Apr 2017, 07:19
Location: Germany
Contact:

Re: Dedicated Microsoft Teams mute toggle keyboard shortcut

18 Oct 2023, 12:19

Same answer as above. Create an issue in the GitHub repo. I haven't the new client yet but as soon as I have I will update the repo.
User avatar
tdalon
Posts: 44
Joined: 21 Apr 2017, 07:19
Location: Germany
Contact:

Re: Dedicated Microsoft Teams mute toggle keyboard shortcut

23 Oct 2023, 03:56

tdalon wrote:
18 Oct 2023, 12:19
Same answer as above. Create an issue in the GitHub repo. I haven't the new client yet but as soon as I have I will update the repo.
I have updated the repo now to support the New Teams client

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 132 guests