Activate SideCar to Enable iPad as a Second Monitor

I'm looking to create a macro wherein I can easily turn side car on and off without having to go to System Preferences --> Displays --> Add Display. I am totally new to using KM so I apologize if this is overly simple request. Thank you

2 Likes

I suspect this will help. AppleScript to Toggle Sidecar - My Blog There is a keyboard maestro action to run an AppleScript that can be used to run the script from that blog post. I'd set it up and test it myself, except I don't have an iPad, and you'll learn a lot setting it up yourself as well.

Do come back and ask if that doesn't get you started.

For some people the upcoming feature called Universal Control will eliminate their need for Sidecar. These two features are not the exact same thing, but provide similar results. Universal Control is available in Beta right now for those who want it.

I wonder if KM is going to be impacted by Universal Control. Hmm.

This might be a challenge on Monterey now that Sidecar isn't its own pane in System Preferences. There is probably some less-than-simple UI scripting approach, similar to what @vincent_ardern linked to, but I don't think that particular flavor will work on Monterey.

I’m also struggling with making a script to enable sidecar. Seems none of the available scripts work with Monterey.

Are you asking for an AppleScript script, or a shell script, or a KM script? When you say "none of the available scripts" are you talking about AppleScript scripts?

Using KM, I think you can enable Sidecar in at least two different ways.

  1. Open System Preferences / Display / Click Add Display.
  2. Open Control Center / Display / Click Connect To.

These two methods may not be what you want. I realize that. But they absolutely should work. I could probably create a macro for you, but it may be dependent on things like whether you use "dark mode", or your screen resolution, or other factors that I can't say in advance because I can't see your screen right now.

In a little while some people will stop using Sidecar because Universal Control is coming out shortly. Universal Control is not the same things as Sidecar, but for some people UC may even be a better solution for their needs. Basically Sidecar is an extension for a Mac's monitor, while UC allows the iPad to keep its own screen (iPadOS) while you share the mouse across iPad and MacOS screens.

This is the macro that I use to open SideCar on macOS Monterey with my iPad:

Add Display.kmmacros (4.7 KB)

The AppleScript started out from the example by @vincent_ardern which I then played around with to update for Monterey.

There may be other/better ways to do this, I am new to Mac, Keyboard Maestro and AppleScript, but it has worked for me every time. In the AppleScript, update the click menu item "iPad" of menu 1 and change iPad to the name of your iPad/device, as it appears in the Displays menu.

Hope this helps.

If you are that new, and are already using such a great solution as that, then I should pack up and go home because you are a much better person than me.

But seriously, I'm glad for you. Good job. That's a fine solution.

1 Like

@Sleepy Thank you for the kind words. I know (hope!) you were joking; I am certainly not a "better person" than you, or anybody else. I got my first Mac just over 2 months ago but I have been creating iOS Shortcuts since Workflow days. In the dim and distant past i worked as a VMS and Unix admin and even then used to try to automate tasks with shell scripts. It's because of people like you and the other members of this and other similar formus that we can all gain the benefit of each others' experience.

Yes, I was joking. And I'm glad you noticed I was being silly. (I did say "But seriously....") On a forum like this one must be extremely careful how they write. Not everyone understands sarcasm, for example. And not everyone even understands English. Most of the posts that I write I write twice: the first draft I look at it and try to see how it could be misinterpreted; then I erase everything and start over to try to be clearer.

Thanks for answering, and sorry for the ambiguity. I was thinking about doing this using an apple script. I guess I could use KM functions to do the same thing, but it didn’t seem like the right solution.

I got stuck at finding the right syntax for pressing the drop down item to add my iPad as an extra screen in the display pref panel.

Thanks! This is exactly what I was looking for. I couldn’t find the correct syntax for clicking the drop down menu, but it seems you figured it out! I’ll try it in a few days when I get home and have access to my Mac again!

1 Like

I've had some time to test this now. I had two problems:

  1. The menu would not be clicked for some reason (race condition)?
  2. The macro would execute twice if triggered by the usb attached condition.

I think I managed to solve both of the issues.
My apple script now looks like this (using Swedish window names etc):

I also added a semaphore to help with the multiple triggers problem. I hope this can help someone else running into these issues.

This is my version of the AppleScript (for Monterey)

It opens the Displays Pane without requiring fixed delays, accounts for different iPad names (but must have 'iPad' in your iPads name, else tweak script), and accounts for selecting the "Mirror or extend to" option when the "Link Keyboard and Mouse" option appears in the same menu…

I used WightWizards apple script above and it worked great. BUT
over the past couple of weeks since I updated the IOS software - I have found my Ipad disconnects randomly as quickly as within a minute to up to an hour later.

I doubt this is a KM issue or AppleScript - but I thought I'd throw it out to see if this is a known issue with a known solution.

Thank you,
G

Hi there,

so none of the above Macros worked for me (Monterey 12.4 on M1), so i combined them and this is what worked.
Perhaps it is useful to someone else... :slight_smile:

Add Display.kmmacros (4.7 KB)

In fact, the macro acts as a toggle between SideCar and Universal Control. I run the macro via a Better Touch Tool gesture, though one could certainly continue to use KBM as well if you have a preference for hot-keys

Hello everyone ! The macro does not work on my m1 MacBook Pro. Can I have some help ?

@Rosam, does this work for you ?

Hi, I am using the German version of Mac OS X. How can I inspect the name of the pop-up button? I only see a plus sign as a pop-up menu. Thank you