Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Set Dock auto-hide state via AppleScript System
There are dozens of hints that programatically toggle the Dock's auto-hide state. Some suggest modifying com.apple.Dock, then killing the dock. Others rely on sending keystrokes to merely toggle the dock state.

Neither of these give the user elegant control over the state of the dock. So, I've written a small snippet of AppleScript combining these ideas, giving absolute control over the Dock's hiding state without killing the dock or modifying the plist. This is suitable for use in any situation where you want to allow the user to control the Dock's visibility state in your AppleScript code:
set weWantToHideTheDock to true

set currentDockHiddenState to (do shell script "defaults read com.apple.Dock autohide")

if (currentDockHiddenState is equal to "0") and (weWantToHideTheDock) then
  tell application "System Events"
    keystroke "d" using [command down, option down]
  end tell
else
  if (weWantToHideTheDock is false) and (currentDockHiddenState is equal to "1") then
    tell application "System Events"
      keystroke "d" using [command down, option down]
    end tell
  end if
end if
Your script will need to set weWantToHideTheDock. If set to true, the Dock will switch to auto-hide mode; setting it to false will disable auto-hiding. It's not a toggle, so if the Dock is already hidden and weWantToHideTheDock is set true, the Dock will stay hidden.

[robg adds: The above code isn't necessarily meant to be used as a standalone solution -- clearly it's much simpler to just press Command-Option-D if you want to toggle your Dock's visibility state. Instead, it's a snippet of code for use in larger programs.]
    •    
  • Currently 3.57 / 5
  You rated: 5 / 5 (14 votes cast)
 
[10,931 views]  

Set Dock auto-hide state via AppleScript | 4 comments | Create New Account
Click here to return to the 'Set Dock auto-hide state via AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Set Dock auto-hide state via AppleScript
Authored by: simsamsep on Mar 19, '10 12:40:43PM

Option-Command-D does nothing in 10.5.8. Maybe a Snow Leopard feature?



[ Reply to This | # ]
Set Dock auto-hide state via AppleScript
Authored by: simsamsep on Mar 19, '10 12:44:21PM

Sorry. Option-Command-D does work in 10.5.8. I had forgotten that I disabled it.



[ Reply to This | # ]
Set Dock auto-hide state via AppleScript
Authored by: DavidMLewis on Mar 22, '10 05:50:48PM
You can do it much more simply with pure AppleScript: tell application "System Events" to set the autohide of the dock preferences to true will hide it, and obviously setting it to false with unhide it.

[ Reply to This | # ]
Set Dock auto-hide state via AppleScript
Authored by: Andrew J Freyer on Mar 23, '10 11:33:25PM

Much better than mine!

---
Easier location-based computing: with Airport Location, app for 10.6. It's an early Beta, so please report bugs!

http://airportlocation.blogspot.com



[ Reply to This | # ]