Help Needed: Automating Video Call Reactions on macOS

Greetings,

I’m attempting to automate the “Confetti” reaction effect during a video call on macOS. I’ve encountered a snag with the green video menu bar icon, which moves around depending on the number of items in the menu bar. If the icon isn’t visible, I’d like the script to show an error message and exit.

Here’s the revised pseudocode for what I’m trying to achieve:

// Pseudocode for triggering the "Confetti" reaction in a video call
TRY
    OPEN green video menu bar icon
    IF green button is not visible THEN
        DISPLAY "Error: Green button not found."
        EXIT script
    END IF
    EXPAND "Reactions" submenu
    SELECT "Confetti" effect from the submenu at position [2,2]
CATCH any errors
    DISPLAY error message
END TRY

I’m considering using Automator or AppleScript for this task. Below are the steps I need help with, along with placeholders for screenshots:

  1. Open the Green Video Menu Bar Icon:

    • Description of the step.
  2. Expand the ‘Reactions’ Submenu:

  3. Select the ‘Confetti’ Effect:

    • Description of the step.

Any assistance or examples, especially from those experienced with macOS automation, would be greatly appreciated. For reference, here’s the official Apple support page on the topic: Apple Support Article.

I even prefer terminal command to do this, I have RayCast that I prefer to trigger this automation from it, I also use Hidden for menu bar items (but it is impossible that it hides the video call menu icon, which is a good thing).

Thank you for your time and help!

This works for me (macOS Sonoma 14.5 / German Language):

tell application "System Events"
	tell application process "ControlCenter"
		-- Check if the Green Video Menu Bar Icon exists
		if (first menu bar item of menu bar 1 whose value of attribute "AXIdentifier" is "com.apple.menuextra.audiovideo") exists then
			set theBarItem to (first menu bar item of menu bar 1 whose value of attribute "AXIdentifier" is "com.apple.menuextra.audiovideo")
			-- Open the Green Video Menu Bar Icon
			tell theBarItem
				perform action "AXPress"
			end tell
			tell group 3 of group 1 of window 1 -- Possibly Group 4 if ‘Center Stage’ is available!
				-- Save current ‘Reactions’ State and set to enabled
				tell checkbox 1
					set savedValue to value
					set value to 1
				end tell
				-- Expand the ‘Reactions’ Submenu
				tell UI element 2
					perform action "AXPress"
				end tell
				-- Select the ‘Confetti’ Effect
				tell button 2 of group 2
					perform action "AXPress"
				end tell
				-- Collapse the ‘Reactions’ Submenu
				tell UI element 2
					perform action "AXPress"
				end tell
				-- Set ‘Reactions’ State to saved state
				tell checkbox 1
					set value to savedValue
				end tell
			end tell
			-- Close the Green Video Menu Bar Icon
			tell theBarItem
				perform action "AXPress"
			end tell
		end if
	end tell
end tell

If you need a Shell Script, you can embed the code like this:

#!/bin/bash
osascript <<EOF
	...
EOF

Automating Video Call Reactions on macOS

2 Likes

It worked—thank you.

Regarding handling the two scenarios: with and without the Center Stage feature, what would be the best approach to count for each case?

It seems to always be the last option (group). Try this:

tell application "System Events"
	tell application process "ControlCenter"
		-- Check if the Green Video Menu Bar Icon exists
		if (first menu bar item of menu bar 1 whose value of attribute "AXIdentifier" is "com.apple.menuextra.audiovideo") exists then
			set theBarItem to (first menu bar item of menu bar 1 whose value of attribute "AXIdentifier" is "com.apple.menuextra.audiovideo")
			-- Open the Green Video Menu Bar Icon
			tell theBarItem
				perform action "AXPress"
			end tell
			tell last group of group 1 of window 1
				-- Save current ‘Reactions’ State and set to enabled
				tell checkbox 1
					set savedValue to value
					set value to 1
				end tell
				-- Expand the ‘Reactions’ Submenu
				tell UI element 2
					perform action "AXPress"
				end tell
				-- Select the ‘Confetti’ Effect
				tell button 2 of group 2
					perform action "AXPress"
				end tell
				-- Collapse the ‘Reactions’ Submenu
				tell UI element 2
					perform action "AXPress"
				end tell
				-- Set ‘Reactions’ State to saved state
				tell checkbox 1
					set value to savedValue
				end tell
			end tell
			-- Close the Green Video Menu Bar Icon
			tell theBarItem
				perform action "AXPress"
			end tell
		end if
	end tell
end tell

PS: You can also select other effects by changing this line:

tell button 2 of group 2

For example, tell button 3 of group 1 selects ‘thumbs down’ etc.

When the script runs in full screen mode, it fails to function properly as it cannot access the Reactions submenu. Although it successfully opens the green video’s menu bar in the Control Center, it does not proceed to the Reactions submenu.

EDIT: This happens when automatically hide and show menu bar is activated for full screen.

I think the problem is the menubar being hidden, although it successfully opens the green video button menu.

tell application "System Events"
	tell application process "ControlCenter"
		-- Check if the Green Video Menu Bar Icon exists
		if (first menu bar item of menu bar 1 whose value of attribute "AXIdentifier" is "com.apple.menuextra.audiovideo") exists then
			set theBarItem to (first menu bar item of menu bar 1 whose value of attribute "AXIdentifier" is "com.apple.menuextra.audiovideo")
			-- Open the Green Video Menu Bar Icon
			tell theBarItem
				perform action "AXPress"
			end tell
			-- Wait for the window to open
			set timeoutDate to (current date) + 2
			repeat while (not (window 1 exists)) and ((current date) < timeoutDate)
				delay 0.01
			end repeat
			tell last group of group 1 of window 1
				-- Save current ‘Reactions’ State and set to enabled
				tell checkbox 1
					set savedValue to value
					set value to 1
				end tell
				-- Expand the ‘Reactions’ Submenu
				tell UI element 2
					perform action "AXPress"
				end tell
				-- Select the ‘Confetti’ Effect
				tell button 2 of group 2
					perform action "AXPress"
				end tell
				-- Collapse the ‘Reactions’ Submenu
				tell UI element 2
					perform action "AXPress"
				end tell
				-- Set ‘Reactions’ State to saved state
				tell checkbox 1
					set value to savedValue
				end tell
			end tell
			-- Close the Green Video Menu Bar Icon
			tell theBarItem
				perform action "AXPress"
			end tell
		end if
	end tell
end tell

Hello Dirk,

I’ve recently crafted a Raycast extension, heavily influenced by the ingenuity of your AppleScript. It’s up and running, which you can check out here: GitHub link. I’m reaching out to see if you’d be interested in being credited as a contributor. Your insights could greatly enhance the extension, and if you’re open to it, I’d welcome any improvements you might want to push to the GitHub repo. Alternatively, if you’d prefer a mention as an contributor, that would be equally appreciated.

Let me know your thoughts when you have a moment.

Warm regards,

Hi,

Thank you for the information and the offer. However, I would prefer to work in the background.
One reason for this is that it is UI scripting. Therefore, it is very dependent on the macOS version and has to be adapted accordingly with every small change. Unfortunately, there is often no other way to implement things, but fortunately macOS offers this option at all.
The other thing is that I currenytly only use BetterTouchTool and PopClip because each app ultimately consumes resources in the background and both apps contain everything I need. This is essentially the ability to execute a script via shortcuts, and BTT in particular with the ability to use “FN + Your Key” is pretty much unbeatable (including the on-board actions, many of which even make the scripts obsolete). Raycast sounds exciting and I have tried it, but for the reasons I have mentioned, I don’t see why I would need it. But that’s my personal opinion and as a Mac user for the last 20 years, I’m probably no longer up to date.

But of course you can always contact me if you have any questions or problems, and you can also publish parts of my code under your name.
I will also keep an overview of the subject from my side with the upcoming macOS updates (Apple has already announced changes to the Control Centre) and post an update of the script in this topic if necessary.

Best regards
Dirk

PS: Great Job!

1 Like