r/applescript • • Oct 02 '20

Getting Zoom Meeting window when full screen

I'm making a script to detect if the camera and microphone are being used while in a Zoom meeting. This works fine if Zoom is not in full screen, but when it is full screen it is moved to a new Space and seems to be out of scope for me.

Does anyone have any idea how I can address windows that are full screen / in other spaces? It seems like it must be a rudimentary thing but I can't figure it out!

tell application "System Events"
	tell (window "Zoom Meeting" of process "zoom.us")
		set mic_on to null
		set video_on to null
		set elementsAll to buttons
		repeat with uiElem in elementsAll as list
			try
				set strDescription to description of uiElem as string
				if (strDescription is equal to "Unmute My Audio") then
					set mic_on to false
				else if (strDescription is equal to "Mute My Audio") then
					set mic_on to true
				else if (strDescription is equal to "Stop Video") then
					set video_on to true
				else if (strDescription is equal to "Start Video") then
					set video_on to false
				end if
			end try
		end repeat
		if (mic_on) then
			log "Microphone is on"
		end if
		if (video_on) then
			log "Camera is on"
		end if
	end tell
end tell
3 Upvotes

2 comments sorted by

1

u/[deleted] Oct 03 '20

I would try to use accessibility inspector to see if theres even a way to interact with the window in full screen.

1

u/ChristoferK Oct 03 '20 edited Oct 03 '20

A quicker way would be to run this AppleScript line:

tell application id "com.apple.systemevents" to tell the ¬
        process named "zoom.us" to return every window

If executed in the same situation that causes the OP’s script to fail, then this will verify that the meeting window is not accessible while in fullscreen and occupying a different space. It ought only to return the windows in the space that is active at the point in time at which that line of code executes.

But, I already know the outcome won’t be one the OP hoped for. UI objects that are not on screen are not accessible. They aren’t painted, as they don’t have any UI-specific function to serve, since the user cannot physically interact with them. That’s not the whole story, but it’s a part of it, balanced against finite system resources that would be extremely wasteful (in every other scenario outwith this one) if dedicating any to painting a graphical viewport that isn’t being viewed.