在 iOS 12 發佈之後,最好玩的功能莫屬集成到系統的捷徑,也就是以前的 workflow 了,配合 workflow 能夠完成一連串的操做,在這裏主要演示下在手機上經過 Siri 語音控制 Mac 完成辦公環境的初始化。shell
最近又研究了下,發現能夠更進一步,配合語音完成 Mac 的解鎖並自動登陸微信,解鎖 Mac 須要在 App Store 購買 Unlox(固然若是你有 Apple Watch 的話當我沒說)服務器
打開 Mac 自帶的腳本編輯器,輸入一下代碼:微信
-- active app on active(appName, isfull) if application appName is not running then tell application appName activate end tell if isfull is equal to 1 then fullScreen() end if if appName is equal to "iTerm" then initIterm() end if if appName is equal to "WeChat" then weChatLogin() end if end if end active -- init iTerm on initIterm() tell application "iTerm" tell current window create tab with default profile tell current tab tell application "System Events" keystroke "ssh user@ip" keystroke return delay 2 keystroke "password" keystroke return end tell end tell end tell end tell end initIterm -- full screen on fullScreen() delay 1 tell application "System Events" keystroke "f" using {control down, command down} end tell end fullScreen -- init samba connect on initSamba() tell application "Finder" open location "smb://user:password@ip" end tell end initSamba -- WeChat Login on weChatLogin() tell application "System Events" to tell process "WeChat" set frontmost to true click at {640, 440} end tell end WeChatLogin -- main initSamba() active("iTerm", 0) active("Mail", 0) active("DingTalk", 0) active("Visual Studio Code", 1) active("Google Chrome", 1) active("WeChat", 0)
說明:app
/Users/username/Desktop/init.scpt
,此時能夠直接運行這個腳原本驗證程序是否 OK,運行過程當中可能回須要容許一些輔助功能的權限url
, 選擇第一個,把操做一複製的 schemes
添加到 url
下的輸入框url
, 選擇 打開url
ssh
,選擇搜索出來的選項在密碼下邊的輸入框中輸入ssh
osascript /Users/username/Desktop/init.scpt
大功告成!編輯器