Hello together! So, based on @mikelxc great Sidecar Toggle I made one with an easy setup.
Hold it to enter the name of your iPad and you're free to go, nothing needs to be changed in the code itself.
No design changes.
@Caliguvara
It seems like the preset isn't working (returns "cannot find any iPads to connect to" error message). This is despite me connecting to the iPad using Sidecar numerous times. Any ideas why? Thanks
Spent several hours fighting with Monterey to get access to "Control Center" window contents.
Which (for me at least) is returned as {}... the first time I try to access it.
After that weird quirk, it behaves as it should. Or so it seems.
I'm sure the next macOS patch release will obliterate the utility of this script.
Enjoy while you can~
-- BTT Sidecar Widget Setup
-- AppleScript gymnastics for macOS Moneterey 12.01
tell application "BetterTouchTool"
try
set LclOldiPadName to get_string_variable "iPadWg_DevceName"
on error
set LclOldiPadName to "iPad"
end try
end tell
tell application "System Events"
tell its application process "ControlCenter"
try
-- changes names: "Display", "Display, Sidecar On"
click (the first menu bar item of menu bar 1 whose title contains "Display")
tell its window "Control Center"
-- initial READ is somehow required to actually access contents
set empty_obj to entire contents
click checkbox LclOldiPadName of scroll area 1
end tell
click (the first menu bar item of menu bar 1 whose title contains "Display")
on error
display dialog "Cannot find any iPads available right now"
end try
end tell
end tell