Webcam and Mic on/off as conditions

I'd love to have a condition for mic and webcam on/off.

Use case - one button to mute/unmute zoom when in other apps, but I want to show a relevant HUD with either "Muted" or "Unmuted" to know the status. Not sure if this is already implemented, please let me know if it is.

In the current alpha something called "dynamic variables" has been added. This can be used for the Mic, but unfortunately I don't think there is an easy way to check whether the camera is in use.

This allows to create variables that run some Java Script & Apple Script / Shell Script:

(async () => {

let appleScript = `input volume of ( get volume settings )`;
let inputVolume = await runAppleScript(appleScript);

if(inputVolume < 1) {
    returnVariableValue("Mic Off");
} else {
    returnVariableValue("Mic ON");
}

})();

You can also use such variables directly in the HUD when wrapping them in curly braces (e.g. {dynamic_mic_state}

Sounds great! When I create the variable with the script you provided, it always returns MIC ON, whether it's muted in zoom or not. What can be the issue?

Mh it correctly returns Mic OFF for me if the input volume is zero :-/
Maybe there is a difference between input volume 0 and muted? Unfortunately Apple Script doesn't provide any other muted state.

How do you mute the Mic?

I send a cmd+A keyboard shortcut to zoom app and it works whatever other app I send it from. However, I'd like to have a HUD with a relevant mic status to know if I turned it off or on without having to go to zoom and checking.

Oh that is not changing the system input mic volume, just some internal setting of zoom. I don't think BTT can retrieve that value.

If you'd instead use this Apple Script to set the Mic volume system wide it should work:

set MicLevel to input volume of ( get volume settings )
if MicLevel is 0 then
set volume input volume 100
else
set volume input volume 0
end if

//edit: somebody created a script to retrieve the muted state from zoom, it's a bit hacky but looks like it could work:
Get Zoom Mute/Unmute Status (github.com)

Wow! This script works! Any chance I can use its return value as a condition?

You can use this in combination with the script posted initially:

Sorry, I was talking about the apple script you referred to. Is there any way I can use the returned value from the apple script as a condition? Maybe I can show the returned value in the HUD? It would work for me

property btnTitle : "Mute audio"

if application "zoom.us" is running then
  tell application "System Events"
  	tell application process "zoom.us"
  		if exists (menu item btnTitle of menu 1 of menu bar item "Meeting" of menu bar 1) then
  			set returnValue to "Unmuted"
  		else
  			set returnValue to "Muted"
  		end if
  	end tell
  end tell
else
  set returnValue to ""
end if

return returnValue

Sure you can just put it into the dynamic variable script:

(async () => {

let appleScript = `property btnTitle : "Mute audio"

if application "zoom.us" is running then
  tell application "System Events"
    tell application process "zoom.us"
        if exists (menu item btnTitle of menu 1 of menu bar item "Meeting" of menu bar 1) then
            set returnValue to "Unmuted"
        else
            set returnValue to "Muted"
        end if
    end tell
  end tell
else
  set returnValue to ""
end if

return returnValue`;


let isZoomMuted = await runAppleScript(appleScript);
returnVariableValue(isZoomMuted)

})();
1 Like

This works just PERFECT with the HUD notification I've made for Zoom Mic on/off. Thank you so much.

1 Like