Catalina Sidecar toggle

The Control Center no longer responds to click events from any script. But the version with the menu bar should still work with a small change.

Try this (I couldn't test it as I don't currently have an iPad):

set iPadName to "iPad"

tell application "System Events"
	tell application process "ControlCenter"
		repeat with tElement in menu bar items of menu bar 1
			if (exists attribute "AXTitle" of tElement) then
				if value of attribute "AXTitle" of tElement contains "Display" then
					set theBar to tElement
					tell theBar
						click
					end tell
					set tElements to entire contents of window 1
					set tElements to entire contents of window 1 -- bug in 12.x
					repeat with i from 1 to count of tElements
						set tElement to item i of tElements
						if (title of tElement contains iPadName) then
							tell tElement
								click
							end tell
							exit repeat
						end if
					end repeat
					tell theBar
						click
					end tell
					exit repeat
				end if
			end if
		end repeat
	end tell
end tell

Note: The menu "Display" (Settings -> Dock & Menu bar -> Display) must be always visible in the menu bar. See: Catalina Sidecar toggle - #23 by Dirk

1 Like