mac系统中的applescript

本文记录常用的applescript脚本
说hello world

say "hello world"
beep 2

隐藏桌面

do shell script "defaults write com.apple.finder CreateDesktop -bool FALSE;killall Finder"

显示桌面

do shell script "defaults delete com.apple.finder CreateDesktop;killall Finder"

开启黑暗模式和关闭黑暗模式

tell application "System Events"
	tell appearance preferences
		set dark mode to not dark mode
	end tell
end tell

清空垃圾桶

tell application "Finder"
    empty the trash
end tell

发送iMessage


NSAppleScript
https://developer.apple.com/documentation/appkit/nsapplescript

executeAndReturnError方法

你可能感兴趣的:(mac,applescript)