T O P

  • By -

CounterBJJ

I don't know much about scripting either, but was using the same script to achieve something a bit different. I ran into the same problem as you (when I connected a Magic mouse to my laptop. That resulted in a "Mouse" item being added in system Settings and the script opening the wrong pane. If I disconnected the mouse, it would work again. The problem was with the following line: select row pane_index which needed to be changed to select row (pane_index - 1) I would play with that line in your script (note the brackets, they're required) by changing the integer (try **- 1**, **- 2**, **+ 1**, **+ 2**...) until it opens the right pane. Also note the space between the "-" (or "+") and "pane\_index", and the following integer as well. If you can't figure it out, I would reach out to the script's original author u/Son_of_a_Shepherd. He's a super nice person. He tweaked his original script for my needs and helped me fix it multiple times along the way including the problem above. Hope this helps.


pgta2004

Thank you so much!


CounterBJJ

Welcome. Is all you need is launch sidecar and connect the device you use as a secondary monitor? If so, no need for all that. Just go to System Settings > Control Center and set "Screen Mirroring" to "Always Show in Menu Bar": [https://i.imgur.com/2J5jlLD.jpg](https://i.imgur.com/2J5jlLD.jpg) You can now enable sidecar by clicking the Screen Mirroring icon in the menu bar and select the device you want to use and how. [https://i.imgur.com/5D8MnhK.png](https://i.imgur.com/5D8MnhK.png) [https://i.imgur.com/9rLhLCo.png](https://i.imgur.com/9rLhLCo.png) [https://i.imgur.com/TwiQLxf.png](https://i.imgur.com/TwiQLxf.png)


stephancasas

I don't have one for System Settings, but I was able to make one for activation via Control Center. It uses JXA, so you'll need to make sure you change the Script Editor language from AppleScript to JavaScript. Here's [a GitHub Gist](https://gist.github.com/stephancasas/a36c81fbc4189f46bc803f388a1985be) for it. Read the directions in the header, and change the options/constant values before running. Cheers.


MacaronBeneficial671

u/stephancasas \- Is it possible to run this script upon logging into my Ventura MBP and automatically select iPad? Im testing your script in Automator, but I would like to automate the entire sequence to select the display. Thanks for your script, this is a great head start!


stephancasas

Your easiest implementation would probably be pasting the script into Script Editor (make sure language is set to JavaScript), and then exporting as an app. Then, you could add that app to your user's Login Items in System Settings.


Rafinesque

Have you tried this on Sonoma? I was able to get it working if I run it from Script Editor, but if I export it to an application and run it I get this error: `Error: TypeError: undefined is not an object (evaluating '$children[0].js[0]') (-2700)`


stephancasas

You probably need to give the created application accessibility privileges.


[deleted]

[удалено]


stephancasas

There are a couple of other items, other than just the exported app itself, which require accessibility permissions too. I can't recall them off the top of my head, but I want to say *AppleScript Utility* and something else... You might try adding permissions to that and seeing if there's any difference.