[教學] Mac mini開機時自動啟動sidecar的script

看板MAC作者時間3年前 (2021/03/27 22:31), 3年前編輯推噓6(602)
留言8則, 6人參與, 3年前最新討論串1/1
https://i.imgur.com/ASaronx.jpg
有好幾位版友寫信來跟我要這個script 這個script的用途是沒有外接螢幕時 把iPad當成mini的外接螢幕 但這樣做要克服一個問題 因為沒有外接螢幕 所以必須要在開機時自動啟動sidecar 讓mini能夠連接iPad當成螢幕使用 要注意我的ipad名稱就叫iPad 如果版友有別的命名要記得改 set deviceName to "iPad" -- Change this to the name of your iPad set displayM enu to "" -- Do not change this tell application "System Events" tell its ap plication process "ControlCenter" -- Get all menu bar items. set menuBarIt ems to menu bar items of menu bar 1 -- Determine if the Display menu is i n the menu bar. repeat with mbi in menuBarItems if name of mbi contains " 顯示器" then set displayMenu to mbi end if end repeat -- If the Display menu is in the menu bar, get the Sidecar device. -- In Big Sur, it's a toggle button (checkbox) instead of a menu item. if displayMenu is not eq ual to "" then click displayMenu set deviceToggle to checkbox 1 of scrol l area 1 of group 1 of window "控制中心" whose title contains deviceName -- Click the device. click deviceToggle -- The menu name changes w hen Sidecar is active, so we need to get the Display menu again, then click to close it. set displayMenu to (first menu bar item whose name con tains "顯示器") of menu bar 1 click displayMenu else -- If the Display menu isn 't in the menu bar, display an error message. set errorMessage to "Display menu not found in menu bar. Open System Preferences > Dock & Menu Bar. Set Dis play to \"Show in Menu Bar > Always.\"" display dialog errorMessage with ic on caution end if end tell end tell -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.41.224.55 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/MAC/M.1616855502.A.6DF.html ※ 編輯: wayne4321 (223.139.155.160 臺灣), 03/27/2021 22:32:39

03/28 02:31, 3年前 , 1F
測試成功,感謝教學 提醒一下 conta示器")有漏字
03/28 02:31, 1F
真的噎 我補上去了 我再傳一份到雲端好了 Moptt好奇怪 會吃字 https://drive.google.com/file/d/19Ln0Gy_BBN1prSaT33FunlZqSRKYDTLZ/view?usp=sha ring

03/28 02:53, 3年前 , 2F
03/28 02:53, 2F
※ 編輯: wayne4321 (114.41.224.55 臺灣), 03/28/2021 04:53:18

03/28 08:11, 3年前 , 3F
感謝分享。
03/28 08:11, 3F

03/28 10:01, 3年前 , 4F
推分享!
03/28 10:01, 4F

03/28 14:17, 3年前 , 5F
我是透過ipad執行捷徑後可成功開啟Sidecar,但剛開機
03/28 14:17, 5F

03/28 14:17, 3年前 , 6F
處在登入畫面時無法順利啟動,這部分有解嗎?
03/28 14:17, 6F

03/28 18:58, 3年前 , 7F
要設定成自動登入
03/28 18:58, 7F

03/28 19:43, 3年前 , 8F
你也可以貼到 GitHub Gits 上面
03/28 19:43, 8F
※ 編輯: wayne4321 (114.41.226.115 臺灣), 03/29/2021 06:41:57
文章代碼(AID): #1WNq7ERV (MAC)