Skip to content

Instantly share code, notes, and snippets.

@chatchavan
Created July 3, 2022 09:57
Show Gist options
  • Save chatchavan/6e60982b80b96a3be155023a5afe8d30 to your computer and use it in GitHub Desktop.
Save chatchavan/6e60982b80b96a3be155023a5afe8d30 to your computer and use it in GitHub Desktop.
Toggle iPad Sidecar display (Tested on Monterrey 12.4)
use AppleScript version "2.4"
set iPadName to "ChatPad" -- TODO: Change to the name of your iPad
tell application "System Preferences" to activate
tell application "System Preferences"
reveal pane id "com.apple.preference.displays"
end tell
tell application "System Events"
tell process "System Preferences"
delay 0.8
click window "Displays"
tell pop up button "Add Display" of window "Displays"
click
delay 0.8
tell (last menu item of menu 1 whose name contains "ChatPad")
click it
end tell
end tell
end tell
end tell
tell application "System Preferences" to close window 1
@nuynait
Copy link

nuynait commented Aug 17, 2022

Can't get window "Displays" of process "System Preferences"

@chatchavan
Copy link
Author

Just tested it today, and it works on my mac (Monterey 12.5).

Check if the system preference window shows up. If not, try adding "delay 0.8" at line 10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment