Check if zoom meeting is muted or unmuted

I've created a macro so I can toggle mute and unmute the microphone and change the Mac background when I'm on a Zoom meeting with my work colleague. I trigger this with a keyboard shortcut. I change the desktop background to red when the meeting is muted and green when not muted. I usually stay on the same Zoom meeting all day. That seems to work well when I use the keyboard shortcut to swap between mute and unmute. Ive also set up another macro that changes the background to the default old Sonoma background when the Zoom app exits.
My problem is that the background can sometimes get out of sync of the true mute/unmute status. A meeting can also be muted or unmuted by clicking the Zoom icon in the status bar and clicking on mute(or unmute) in the icon's dropdown menu. Also the other participant(s) might end the meeting on their end and I might end up showing that the Zoom meeting is unmuted but in reality the meeting has ended and ideally the desktop background should be changed from green or red to the default Sonoma background. I don't know how best to deal with these circumstances to ensure my desktop background stays perfectly in sync with the meeting status ie red background if on a meeting and muted, green background if on a meeting and unmuted, and Sonoma background if there is no active meeting. I thought to do a periodic trigger to check the Zoom menu and see 1. if the Meeting menu exists and 2. If the Meeting menu exists to check if the Mute audio (or Unmute audio) submenu exists but I don't believe you can check if a menu exists in a background app. Usually Im working in some other app and when the periodic trigger fires (say each minute or so) I don't want the macro to bring Zoom to the front just to check for the existence of the menu items. Does anyone know how I can best achieve what I'm trying to do.

I sometimes experience my automation macros skipping the Set Wallpaper action, but I don't know why. Other actions that come after execute successfully, and there's nothing in the log. I have to retrigger the macro manually.

In this case though, I would probably do something like this:

old suggestion

Use a Try/Catch action to execute an applescript that checks for the Meeting menu bar item. If the script finds Meeting in the menu bar, then it gets the names of all the available items in that menu and saves them to a variable, which you can then search with regex and use a Switch/Case action to set the appropriate wallpaper based on whether Mute audio or Unmute audio was found. Otherwise (ie the applescript fails to find the Meeting menu bar item), set the Sonoma wallpaper.

You could use Application Trigger for some time interval to check if Zoom is running—that would be the most straightforward. But I would probably use the Chron Trigger instead in conjunction with a second macro that would enable/disable this macro based on whether Zoom was launched or quit; that would ensure this macro is only ever active and executing while Zoom is actually running.

N.b. There's probably a way to skip the regex step altogether by having the script get the exact menu item directly and save it to the variable. But I've been trying to teach myself regex recently, and it's been influencing my problem solving.

[edit] Of course there's a way to do it directly with applescript. :sweat_smile:

1 Like

While never averse to a bit of AppleScript, @loz's post suggests KM can manipulate Zoom's menus -- and if KM can manipulate them, KM can use them in an "If" condition.

That'll save the expense of instantiating an AppleScript instance that then uses (the relatively slow) "System Events". Plus it's a lot easier to understand the macro at a glance.

Unless I did something wrong, when I tried using an if-statement with a menu condition, Zoom had to be in front, and they said they didn't want Zoom being brought to the front every minute since they're routinely working in other apps while Zoom is open.

My apologies -- I didn't see "background app" amongst all the other "background"s (8 in one paragraph must be some kind of record!).

You're right, of course.

1 Like

Thank you Hemicyon, Im testing your solution ...

I'm not familiar with applescript but ive copied your AppleScript code into Script Editor to test it. When Im not on a Zoom meeting it correctly returns "NOT IN A MEETING", however when I am in a Zoom meeting, it only returns MUTED when I'm Muted but also when I'm not Muted.

When I copy the AppleScript into a Keyboard Maestro macro I get similar results ie during a meeting Im only getting MUTED returned irrespective of if I'm actually Muted or not.

ZoomCheckMicrophoneStatus Macro (v11.0.3)

ZoomCheckMicrophoneStatus.kmmacros (5.8 KB)

Im not sure why the AppleScript isn't working as I'd expect

Hm. Possibly the menu items are different from the version of Zoom I downloaded to test with. Which versions of macOS and Zoom are you running?

Try running this script while muted and unmuted in a meeting, then post each set of results here:

tell application "System Events"
	tell application process "zoom.us"
		get name of every menu item of menu 1 of menu bar item "Meeting" of menu bar 1
	end tell
end tell

Screenshots of the Meeting menu while muted and unmuted could be helpful as well.

Just back from xmas holidays so sorry for tardy reply.

When Zoom meeting is MUTED and I run that script in Script Editor, it returns the following
{"Fullscreen", "Keep on top", missing value, "Enter minimal view", missing value, "Multi-speaker view", missing value, "Unmute audio", "Start video", "Switch camera", "Start share", missing value, "Invite...", "Copy invite link", missing value, "Record"}

Screen Shot of Meeting menu when meeting is MUTED

When the Zoom meeting is UNMUTED the script returns
{"Fullscreen", "Keep on top", missing value, "Enter minimal view", missing value, "Multi-speaker view", missing value, "Mute audio", "Start video", "Switch camera", "Start share", missing value, "Invite...", "Copy invite link", missing value, "Record"}

Meeting is Unmuted Screen Shot

I have also tried running your original AppleScript in ScriptEditor and again and it still returns MUTED when the meeting is both MUTED and UNMUTED.

It looks like maybe your menu order is different than mine was (I'm afraid I already uninstalled Zoom, so I can't check at the moment).

So in the line that says...

set micopt to name of menu item 10 of menu 1 of menu bar item "Meeting" of menu bar 1

...try changing menu item 10 to menu item 8.

You could also add what I probably should've included to begin with, which is an else if, so actually maybe just try this script instead. If you run it first in Script Editor, you should be able to see immediately if it's grabbing the correct menu item.

try
	tell application "System Events"
		tell application process "zoom.us"
			set micopt to name of menu item 8 of menu 1 of menu bar item "Meeting" of menu bar 1
			if micopt = "Mute audio" then
				return "UNMUTED"
			else if micopt = "Unmute audio" then
				return "MUTED"
			else
				return "wrong menu item"
			end if
		end tell
	end tell
on error
	return "NOT IN MEETING"
end try