Sidecar via applescript

I want to connect to the iPad via universal control, but this script is still missing the last step.
It also needs to click on the device with the name ipad to connect. Can you tell me what other code needs to be added?
My system is monterey 12.5.

tell application "System Events"
	tell its application process "ControlCenter"
		click menu bar item "Control Center" of menu bar 1
		tell its window "Control Center"
			-- Monterey
			if exists checkbox "Screen Mirroring" then
				tell its checkbox "Screen Mirroring"
					perform action 2
					delay 1	
					end tell
				end tell
			else
				-- big sur
				-- "action 1" instead of "action 2"
				if exists (checkbox "Screen Mirroring" of group 1 of group 1) then
					tell its checkbox "Screen Mirroring" of group 1 of group 1
						perform action 1
						delay 1
					end tell
				end if
				-- ventura??
				-- "Screen Mirroring" is inside a "group 1"
				if exists (checkbox "Screen Mirroring" of group 1) then
					tell its checkbox "Screen Mirroring" of group 1
						perform action 2
Here are some details

image
Execute an AppleScript.kmactions (1.5 KB)

Keyboard Maestro Export

A solution was found:

tell application "System Events" to tell process "ControlCenter"
	click menu bar item "Control Center" of menu bar 1
	
	perform action 2 of checkbox "Screen Mirroring" of window "Control Center"
	
	delay 2
	tell window "Control Center"
		click (first checkbox of scroll area 1 whose name starts with "iPad")
	end tell
end tell

Does this just start sidecar?

Yeah, I hope it's connected to the iPad.