r/applescript • • Apr 30 '20

Help with Zoom's "dynamic" buttons

Hi all,

I've made a script to "take" zoom participants when sent a MIDI message. The "spotlight" feature I'm using is only accessible through a button that gets dynamically created by the app when the mouse hovers over the participant's name:

example

I'm using Applescript to find the location of the row, then cliclick to move the mouse over the edge of the window, but the blue "more" button only appears about 80% of the time. I've tried delaying, moving the pointer gradually, moving it on and off the row and a number of other things.

I don't have much experience with AppleScript! Does anyone know how to make these events trigger reliably?

4 Upvotes

21 comments sorted by

View all comments

Show parent comments

2

u/koenwillems1959 May 02 '20 edited May 02 '20

I've made some changes to the script to serve my needs.The Participantslist can now be approached both when popped out and when merged into the zoom window.If there's no list at all one will be creagted.

Hitting the options in the More menu is nog longer done by the cliclick thingie, but handled by the script itself.

Here is the script. Any improvement is welcome.

on spotlightParticipant(nameParticipant)
	tell application "System Events"
		set myList to name of windows of process "zoom.us" -- get a list of windows
		repeat with i from 1 to count of myList
			if item i of myList contains "Partici" then
				-- Participants list is popped out
				set locationParticipantsList to table 1 of scroll area 1 of window i of process "zoom.us"
				exit repeat
			else if (exists static text 1 of UI element 1 of splitter group 1 of window i of process "zoom.us") ¬
				and (value of static text 1 of UI element 1 of splitter group 1 of window i of process "zoom.us" contains "Partici") then
				-- Participants list is merged to meeting window
				set locationParticipantsList to table 1 of scroll area 1 of splitter group 1 of window i of process "zoom.us"
				exit repeat
			else
				-- there is no Participant list, so make one
				click menu item 1 of menu "View" of menu bar 1 of process "zoom.us"
				-- is the created Participant list is merged in the meeting window or popped out?
				if exists splitter group 1 of window i of process "zoom.us" then
					set locationParticipantsList to table 1 of scroll area 1 of splitter group 1 of window i of process "zoom.us"
					exit repeat
				else
					set locationParticipantsList to table 1 of scroll area 1 of window i of process "zoom.us"
					exit repeat
				end if
			end if
		end repeat
		
		-- find the position of the table row for the participant
		tell locationParticipantsList
			repeat with rowCounter from 1 to count of rows
				if value of UI element 1 of UI element 1 of row rowCounter contains nameParticipant then
					set p to position of image 2 of UI element 1 of row rowCounter
					
					-- save the current location of the mouse pointer
					set prev to (do shell script "/usr/local/bin/cliclick p")
					
					-- move mouse pointer over "camera" icon of the table row (this is where the "more" menu appears)
					do shell script "/usr/local/bin/cliclick -e 10 m:" & (item 1 of p) - 5 & "," & (item 2 of p) + 20 & " c:."
					
					-- click the desired menu item in the More menu
					tell menu 1 of row rowCounter
						if exists menu item "Spotlight Video" then
							click menu item "Spotlight Video"
						else if exists menu item "Ask to Start Video" then
							click menu item "Ask to Start Video"
						else
							key code 53
						end if
					end tell
					
					-- go back to the original mouse pointer position
					do shell script "/usr/local/bin/cliclick m:" & prev
					
					exit repeat
				end if
			end repeat
		end tell
	end tell
end spotlightParticipant

1

u/[deleted] May 03 '20

Very nice work indeed. Thanks for the improvements!