Skip to content

Instantly share code, notes, and snippets.

@statik
Last active September 26, 2020 02:55
Show Gist options
  • Save statik/e2b6a099bacfb4626dbdf3a73343b6be to your computer and use it in GitHub Desktop.
Save statik/e2b6a099bacfb4626dbdf3a73343b6be to your computer and use it in GitHub Desktop.
embedded osascript for zoom status
std::string osGetZoomStatus()
{
// ESDDebug("APPLESCRIPT_GET_STATUS: %s", APPLESCRIPT_GET_STATUS);
char *zoomStatus = execAndReturn(
"osascript -e 'set zoomStatus to \"closed\"\nset muteStatus to \"disabled\"\n"
"set viewStatus to \"speaker\"\n"
"set videoStatus to \"disabled\"\nset shareStatus to \"disabled\"\ntell application "
"\"System Events\"\nif exists (window 1 of process \"zoom.us\") then\nset zoomStatus "
"to \"open\"\ntell application process \"zoom.us\"\nif exists (menu bar item "
"\"Meeting\" of menu bar 1) then\nset zoomStatus to \"call\"\nif exists (menu item "
"\"Mute audio\" of menu 1 of menu bar item \"Meeting\" of menu bar 1) then\nif "
"enabled of menu item \"Mute audio\" of menu 1 of menu bar item \"Meeting\" of menu "
"bar 1 then\nset muteStatus to \"unmuted\"\nend if\nelse if exists (menu item "
"\"Unmute audio\" of menu 1 of menu bar item \"Meeting\" of menu bar 1) then\nif "
"enabled of menu item \"Unmute audio\" of menu 1 of menu bar item \"Meeting\" of "
"menu bar 1 then\nset muteStatus to \"muted\"\nend if\nend if\nif exists (menu item "
"\"Start Video\" of menu 1 of menu bar item \"Meeting\" of menu bar 1) then\nif "
"enabled of menu item \"Start Video\" of menu 1 of menu bar item \"Meeting\" of menu "
"bar 1 then\nset videoStatus to \"stopped\"\nend if\nelse if exists (menu item "
"\"Stop Video\" of menu 1 of menu bar item \"Meeting\" of menu bar 1) then\nif "
"enabled of menu item \"Stop Video\" of menu 1 of menu bar item \"Meeting\" of menu "
"bar 1 then\nset videoStatus to \"started\"\nend if\nend if\nif exists (menu item "
"\"Start Share\" of menu 1 of menu bar item \"Meeting\" of menu bar 1) then\nset "
"shareStatus to \"stopped\"\nelse\nif exists (menu item \"Stop Share\" of menu 1 of "
"menu bar item \"Meeting\" of menu bar 1) then\nset shareStatus to \"started\"\nend "
"if\nend if\nend if\nend tell\nend if\nend tell\ndo shell script \"echo zoomMute:\" & "
"(muteStatus as text) & \",zoomVideo:\" & (videoStatus as text) & \",zoomStatus:\" & "
"(zoomStatus as text) & \"zoomView:\" & (viewStatus as text) & "
"\",zoomShare:\" & (shareStatus as text)'");
return std::string(zoomStatus);
}
set zoomStatus to "closed"
set muteStatus to "disabled"
set viewStatus to "disabled"
set videoStatus to "disabled"
set shareStatus to "disabled"
tell application "System Events"
if exists (window 1 of process "zoom.us") then
set zoomStatus to "open"
tell application process "zoom.us"
if exists (menu bar item "Meeting" of menu bar 1) then
set zoomStatus to "call"
if exists (menu item "Mute audio" of menu 1 of menu bar item "Meeting" of menu bar 1) then
if enabled of menu item "Mute audio" of menu 1 of menu bar item "Meeting" of menu bar 1 then
set muteStatus to "unmuted"
end if
else if exists (menu item "Unmute audio" of menu 1 of menu bar item "Meeting" of menu bar 1) then
if enabled of menu item "Unmute audio" of menu 1 of menu bar item "Meeting" of menu bar 1 then
set muteStatus to "muted"
end if
end if
if exists (menu item "Start Video" of menu 1 of menu bar item "Meeting" of menu bar 1) then
if enabled of menu item "Start Video" of menu 1 of menu bar item "Meeting" of menu bar 1 then
set videoStatus to "stopped"
end if
else if exists (menu item "Stop Video" of menu 1 of menu bar item "Meeting" of menu bar 1) then
if enabled of menu item "Stop Video" of menu 1 of menu bar item "Meeting" of menu bar 1 then
set videoStatus to "started"
end if
end if
if exists (menu item "Start Share" of menu 1 of menu bar item "Meeting" of menu bar 1) then
set shareStatus to "stopped"
else if exists (menu item "Stop Share" of menu 1 of menu bar item "Meeting" of menu bar 1) then
set shareStatus to "started"
end if
end if
end tell
end if
end tell
do shell script "echo zoomMute:" & (muteStatus as text) & ",zoomVideo:" & (videoStatus as text) & ",zoomStatus:" & (zoomStatus as text) & "zoomView:" & (viewStatus as text) & ",zoomShare:" & (shareStatus as text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment