“幾鍵式”打開或關閉Mac OS的Internet 共享
Macbook提供了非常簡單易用的Internet共享功能,可以做為一個輕量級的家庭無線路由使用。只要你的mbp能夠上網,那么你的手機、touch和pad的設備就都可以通過wifi共享mbp的網絡,實現無線上網。
具體設置非常簡單,系統偏好設置->共享->Inernet共享->啟動幾個步驟,但是每次點這么幾下,還是很麻煩,我們通過Apple Script和QS這個神器可以讓簡單的操作更簡單。
打開AppleScript編輯器,鍵入如下代碼(供參考):
tell application “System Preferences”
activate
end telltell application “System Events”
tell process “System Preferences”
click menu item “共享” of menu “顯示” of menu bar 1
delay 2
tell window “共享”
click checkbox 1 of row 11 of table 1 of scroll area 1 of group 1
delay 1
if (exists sheet 1) then
if (exists button “打開 AirPort” of sheet 1) then
click button “打開 AirPort” of sheet 1
delay 1
end if
click button “啟動” of sheet 1
else
do shell script “/usr/sbin/networksetup -setairportpower en1 off”
delay 1
end if
end tell
end tell
end tellignoring application responses
tell application “System Preferences” to quit
end ignoring
文件->存儲,保存為腳本文件,例如ws.scpt,然后運行,效果看到了吧。
之后呼出QS,如果你是mac使用者而不知道QS,那么就用Google百度一下。在QS中通過路徑方式找到ws.scpt,運行之。運行一次之后就可以直接通過鍵盤操作了。呼出QS,鍵入ws,應該就可以找到ws.scpt,然后敲回車鍵,搞定。
好了,這下呼出QS,鍵入ws和回車,就能自動開啟或關閉Internet共享了。
身邊越來越多的人開始使用Mac,經常被問道Mac的使用問題和技術問題。遂決定,每天發布一則#Mac技巧#。同時發布于微博和微信公眾賬號“Mac技巧”,微信號sagacity-mac,有微信賬號的童鞋掃描下圖片或搜索微信號即可


浙公網安備 33010602011771號