Skip to content

Instantly share code, notes, and snippets.

@AndrwM
Last active March 11, 2021 15:22
Show Gist options
  • Save AndrwM/1ce9dc10e544c72ca664f3569bd43ddd to your computer and use it in GitHub Desktop.
Save AndrwM/1ce9dc10e544c72ca664f3569bd43ddd to your computer and use it in GitHub Desktop.
BetterTouchTool, Listen For Zoom.app meeting: active || muted || inactive
-- thanks to: https://gist.github.com/jsulak/5cd63e5d5ac1eb6461096b6bb30dcad3
property responseMuted : "Zoom: MUTED"
property responseNotMuted : "Zoom: ACTIVE"
property responseInactive : "" -- Return an empty string
property btnTitleMute : "Mute audio"
property btnTitleUnMute : "Unmute audio"
on is_running(appName)
tell application "System Events" to (name of processes) contains appName
end is_running
-- Return true if zoom meeting is active
on is_zoom_meeting_active()
-- Is zoom even running?
if not is_running("zoom.us") then
return false
end if
tell application "System Events"
tell application process "zoom.us"
if exists (menu bar item "Meeting" of menu bar 1) then
return true
end if
return false
end tell
end tell
end is_zoom_meeting_active
-- Return true/false if mic is active or not
on zoom_status()
if is_zoom_meeting_active() then
tell application "System Events"
tell application process "zoom.us"
if exists (menu item btnTitleMute of menu 1 of menu bar item "Meeting" of menu bar 1) then
return responseMuted
else if exists (menu item btnTitleUnMute of menu 1 of menu bar item "Meeting" of menu bar 1)
return responseNotMuted
end if
end tell
end tell
end if
return responseInactive
end zoom_status
zoom_status()
property btnTitleMute : "Mute audio"
property btnTitleUnMute : "Unmute audio"
on is_running(appName)
tell application "System Events" to (name of processes) contains appName
end is_running
-- Return true if zoom meeting is active
on is_zoom_meeting_active()
-- Is zoom even running?
if not is_running("zoom.us") then
return false
end if
tell application "System Events"
tell application process "zoom.us"
if exists (menu bar item "Meeting" of menu bar 1) then
return true
end if
return false
end tell
end tell
end is_zoom_meeting_active
-- Return true/false if mic is active or not
on get_zoom_meeting_mic_on()
if is_zoom_meeting_active() then
tell application "System Events"
tell application process "zoom.us"
if exists (menu item btnTitleMute of menu 1 of menu bar item "Meeting" of menu bar 1) then
return true
end if
end tell
end tell
end if
return false
end get_zoom_meeting_mic_on
-- Toggle the audio state in zoom
on toggle_zoom_audio_state()
if is_zoom_meeting_active() then
tell application "System Events"
tell application process "zoom.us"
if my get_zoom_meeting_mic_on() then
-- If unmuted, mute
click menu item btnTitleMute of menu 1 of menu bar item "Meeting" of menu bar 1
else
-- If unmuted, mute
click menu item btnTitleUnMute of menu 1 of menu bar item "Meeting" of menu bar 1
end if
end tell
end tell
end if
end toggle_zoom_audio_state
toggle_zoom_audio_state()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment