mikelxc Posted August 3, 2020 Share Posted August 3, 2020 (edited) Use "sc" to enable and disable sidecar. KNOWN ISSUES: only supports English systems at this moment. And you have to turn on "show mirroring options in the menu bar" Download Link https://github.com/mikelxc/sidecar-alfredworkflow/releases/download/sc/Sidecar.alfredworkflow Edited August 3, 2020 by mikelxc Link to comment
Tony D Posted October 7, 2022 Share Posted October 7, 2022 Is there a version that works with MacOS Monterey? Link to comment
Tony D Posted October 7, 2022 Share Posted October 7, 2022 I found a script replacement that seems to work on Monterey 12.6 here: https://github.com/geofftaylor/connect-sidecar/issues/10#issuecomment-1188663732 Link to comment
TomBenz Posted October 7, 2022 Share Posted October 7, 2022 3 hours ago, Tony D said: I found a script replacement that seems to work on Monterey 12.6 here: https://github.com/geofftaylor/connect-sidecar/issues/10#issuecomment-1188663732 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 Link to comment
kraig85 Posted October 10, 2022 Share Posted October 10, 2022 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
TomBenz Posted October 10, 2022 Share Posted October 10, 2022 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
vitor Posted October 13, 2022 Share Posted October 13, 2022 @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
TomBenz Posted October 13, 2022 Share Posted October 13, 2022 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. vitor 1 Link to comment
kraig85 Posted October 20, 2022 Share Posted October 20, 2022 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
Tony D Posted October 26, 2022 Share Posted October 26, 2022 (edited) On 10/21/2022 at 6:23 AM, kraig85 said: Looks like the formatting got lost on your post Kraig. Edited October 26, 2022 by Tony D Link to comment
Tony D Posted November 3, 2022 Share Posted November 3, 2022 Did anyone get a script working in MacOS Ventura 13.0 yet? Link to comment
kraig85 Posted November 10, 2022 Share Posted November 10, 2022 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 Tony D and TomBenz 2 Link to comment
Tony D Posted November 11, 2022 Share Posted November 11, 2022 Thank you @kraig85 - works perfect and is fast! Link to comment
juch3059 Posted November 16, 2022 Share Posted November 16, 2022 Can somebody guide how to install this script in Alfred? Link to comment
kraig85 Posted November 16, 2022 Share Posted November 16, 2022 53 minutes ago, juch3059 said: Can somebody guide how to install this script in Alfred? I've created this workflow template for you (I think) - I've never actually used GitHub before (still a newbie) so fingers crossed it works. https://github.com/kraig85/myalfredworkflows Link to comment
peppy76 Posted December 13, 2022 Share Posted December 13, 2022 hi, is there a way to use this script to share the screen to an appletv? the appletv is named "Wohnzimmer"? Link to comment
dpyy Posted May 7, 2023 Share Posted May 7, 2023 Love the script, but I know I'm being picky here but is there a way to run this without opening system prefs? Link to comment
TomBenz Posted June 12, 2023 Share Posted June 12, 2023 (edited) On 12/13/2022 at 8:36 PM, peppy76 said: hi, is there a way to use this script to share the screen to an appletv? the appletv is named "Wohnzimmer"? Got this AppleScript from a website. It works well on macOS Ventura 13.2 and uses the control center GUI automation. The item that you click on is hardcode in the line - set uiScript to "click checkbox 1 of scroll area 1 of group 1 of window \"Control Center\" of application process \"Control Center\"" Perhaps it can be converted to a more generic workflow. For now, it serve my workflow requirement. @vitor @peppy76 @kraig85 Full AppleScript code: -- Click the “Screen Mirroring” menu bar item. -- delay 2.130212 set timeoutSeconds to 2.0 set uiScript to "click menu bar item 7 of menu bar 1 of application process \"Control Center\"" my doWithTimeout(uiScript, timeoutSeconds) -- Click the “<fill in title>” checkbox. -- delay 0.988109 set timeoutSeconds to 2.0 set uiScript to "click checkbox 1 of scroll area 1 of group 1 of window \"Control Center\" of application process \"Control Center\"" my doWithTimeout(uiScript, timeoutSeconds) -- Type '' -- delay 1.04737 set timeoutSeconds to 2.0 set uiScript to "keystroke \"\"" 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 Edited June 12, 2023 by TomBenz Link to comment
jacobwtyler Posted July 22, 2023 Share Posted July 22, 2023 On 11/10/2022 at 3:59 PM, kraig85 said: 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 Awesome. This script works on MacOS Sonoma as well. I did have to add a delay of 1 second before the quit system settings at the end because it was closing the settings panel before the display was activated but other than that it works as is. Amazing! Link to comment
stephancasas Posted July 22, 2023 Share Posted July 22, 2023 I see a lot of scripts targeting System Settings, but this can be achieved much faster using Control Center. Here's a JXA AppleScript you can paste into an Alfred workflow to toggle Sidecar via control center: https://gist.github.com/stephancasas/a36c81fbc4189f46bc803f388a1985be Cheers. jacobwtyler 1 Link to comment
Tony D Posted July 22, 2023 Share Posted July 22, 2023 How are you using that with Alfred @stephancasas? jacobwtyler 1 Link to comment
stephancasas Posted July 23, 2023 Share Posted July 23, 2023 @Tony D, use the Run Script workflow node, and set the language to /𝚞𝚜𝚛/𝚋𝚒𝚗/𝚘𝚜𝚊𝚜𝚌𝚛𝚒𝚙𝚝 (𝙹𝚊𝚟𝚊𝚂𝚌𝚛𝚒𝚙𝚝). Link to comment
jacobwtyler Posted July 27, 2023 Share Posted July 27, 2023 Holy crap. That java script is magic. You guys are amazing! Thank you for sharing. The other script in this thread that I said was working suddenly stopped working and was giving me an error about "group 1" so I came back here and gave this javascript a try. It looks so complicated compared to the other one but worked perfectly! Really cool stuff. Wish I could make stuff like that. TomBenz 1 Link to comment
TomBenz Posted July 27, 2023 Share Posted July 27, 2023 4 hours ago, jacobwtyler said: Holy crap. That java script is magic. You guys are amazing! Thank you for sharing. The other script in this thread that I said was working suddenly stopped working and was giving me an error about "group 1" so I came back here and gave this javascript a try. It looks so complicated compared to the other one but worked perfectly! Really cool stuff. Wish I could make stuff like that. Works good for iPad. thanks. Getting error for iMac -- let me know tweak to screen mirror to iMac. @jacobwtyler Link to comment
jacobwtyler Posted July 27, 2023 Share Posted July 27, 2023 You’d have to ask @stephancasas. I just copied his work. TomBenz 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now