这是一个为我做的applescript,因为它也是我真正想看到的东西。我不确定它是否会赢得风格点,但我使用 Automator 服务调用它并为其设置键盘快捷键,从那以后我没有抱怨过它。
tell application "System Events"
tell dock preferences
--get the properties list of the dock and set (or assign) it to our variable we'll call "dockprops"
set dockprops to get properties
--in our now "dockprops" list, assign our target dock property ("autohide") to the variable "dockhidestate"
set dockhidestate to autohide of dockprops
--the dock's "autohide" property is a boolean: it's value can only be either true or false
--an "if statement" provides the necessary logic to correctly handle either of these cases in this one single script
if autohide = true then
tell application "System Events"
tell dock preferences to set autohide to not autohide
end tell
else
set autohide to true
end if
end tell
end tell
tell application "System Preferences"
activate
-- tell application "Finder" to tell process "System Preferences" to set visible to false
set the current pane to pane id "com.apple.preference.general"
-- The delays are necessary as far as I can tell
delay 0.5
tell application "System Events" to keystroke tab
delay 0.5
tell application "System Events" to keystroke tab
tell application "System Events" to keystroke tab
tell application "System Events" to keystroke space
tell application "System Events" to key code 13 using {command down}
end tell