在 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
大功告成!编辑器