Jump to content

Sidecar Toggle


Recommended Posts

  • 2 years later...
On 10/7/2022 at 10:03 AM, TomBenz said:

It doesn't work on Ventura. Anybody that can suggest a work around or script update? This is code where it is failing:

 

 

tell application "System Settings"

reveal pane id "com.apple.preference.displays"

end tell

 

Have you tried...

 

do shell script "open -b com.apple.systempreferences /System/Library/PreferencePanes/Displays.prefPane" ?

Link to comment
23 minutes ago, kraig85 said:

 

Have you tried...

 

do shell script "open -b com.apple.systempreferences /System/Library/PreferencePanes/Displays.prefPane" ?

Thanks. This is working. How to integrate this with the overall code? The underlined line is giving error.

 

do shell script "open -b com.apple.systempreferences /System/Library/PreferencePanes/Displays.prefPane"

 

use AppleScript version "2.4"

set iPadName to "iPad" -- TODO: Change to the name of your iPad

 

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.1

tell (last menu item of menu 1 whose name contains iPadName)

click it

end tell

end tell

end tell

end tell

 

tell application "System Settings" to close window 1

Link to comment

@TomBenz System Settings (i.e. on Ventura) are quite broken and not as automatable (let’s hope that is a ”yet”). You’re asking for help on doing GUI automation on unfinished software, so whatever you do now may turn out to be wasted. Plus, most people are not on Ventura, so there are fewer who can help. That is the nature and disadvantage of installing betas.

Link to comment
1 hour ago, vitor said:

@TomBenz System Settings (i.e. on Ventura) are quite broken and not as automatable (let’s hope that is a ”yet”). You’re asking for help on doing GUI automation on unfinished software, so whatever you do now may turn out to be wasted. Plus, most people are not on Ventura, so there are fewer who can help. That is the nature and disadvantage of installing betas.

thanks @vitorI understand and can wait for the official release of Ventura. I installed Ventura after public beta 8/9 recently and it has been working well. Alfred is also working without problem. Just fyi.

Link to comment
On 10/10/2022 at 6:06 AM, TomBenz said:

Thanks. This is working. How to integrate this with the overall code? The underlined line is giving error.

 

do shell script "open -b com.apple.systempreferences /System/Library/PreferencePanes/Displays.prefPane"

 

use AppleScript version "2.4"

set iPadName to "iPad" -- TODO: Change to the name of your iPad

 

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.1

tell (last menu item of menu 1 whose name contains iPadName)

click it

end tell

end tell

end tell

end tell

 

tell application "System Settings" to close window 1

As a temp work around (and hoping Vitor is right with the 'yet' part), I've used this script by placing the screen mirroring icon in the menu bar and copying from automator's watch me do - bearing in mind that my script has British English spellings of centre etc.)

 

-- Click the “Screen Mirroring” menu bar item. set timeoutSeconds to 2.0 set uiScript to "click menu bar item 6 of menu bar 1 of application process \"Control Centre\"" my doWithTimeout(uiScript, timeoutSeconds) -- Click the “<fill in title>” tickbox. set timeoutSeconds to 2.0 set uiScript to "click checkbox 3 of scroll area 1 of group 1 of window \"Control Centre\" of application process \"Control Centre\"" my doWithTimeout(uiScript, timeoutSeconds) on doWithTimeout(uiScript, timeoutSeconds)     set endDate to (current date) + timeoutSeconds     repeat         try             run script "tell application \"System Events\"
" & uiScript & "
end tell"             exit repeat         on error errorMessage             if ((current date) > endDate) then                 error "Can not " & uiScript             end if         end try     end repeat end doWithTimeout

Link to comment
On 11/3/2022 at 2:58 AM, Tony D said:

Did anyone get a script working in MacOS Ventura 13.0 yet?  

ta-da!!

 

do shell script "open -b com.apple.systempreferences /System/Library/PreferencePanes/Displays.prefPane"

use AppleScript version "2.4"

set iPadName to "iPad Pro"

tell application "System Events"

          repeat until (exists window "Displays" of application process "System Settings")

                    delay 0.1

          end repeat

          tell process "System Settings"

                    tell pop up button 1 of group 1 of group 2 of splitter group 1 of group 1 of window "Displays"

                              click

                              delay 0.1

                              tell (last menu item of menu 1 whose name contains iPadName)

                                        click it

                             end tell

                    end tell

          end tell

end tell

tell application "System Settings" to quit

Link to comment
  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...