Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > AppleScripting the Dock

AppleScripting the Dock
Thread Tools
Posting Junkie
Join Date: Nov 2000
Location: in front of my Mac
Status: Offline
Reply With Quote
Jan 27, 2002, 06:17 AM
 
I just wanted to write a little AppleScript which would turn dock hiding on. The idea was that I would save this script as an application and then be able to run it through the terminal like "open /Applications/hide.app" where hide.app would be the script. I would then be able to insert the terminal command "open /Applications/hide.app" in the .xinitrc file, so that dock hiding would be activated when I start XDarwin (I need the extra space when running X11 apps).

My only problem is: How do you script the dock? I wanted to open the AppleScript dictionary for Dock.app but I couldn't find it in the dictionary listing. Do I have to use a Finder class? Isn't there something like:

tell Application "Dock.app"
set Hiding "on"
end tell


Thanks for your help,
Simon
     
Junior Member
Join Date: Apr 2001
Status: Offline
Reply With Quote
Jan 27, 2002, 03:47 PM
 
The Dock isn't scriptable (yet), but you could work around it by writing the hiding state to its preferences file & restarting the dock. This should work, but it requires Mac OS X 10.1.2 for the "do shell script" command:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>set dockhide_state to (do shell script <font color = red>"defaults read com.apple.dock autohide"</font>) as text
if dockhide_state = <font color = red>"<font color = blue>1</font>"</font> then
set theBool to <font color = red>"no"</font>
else
set theBool to <font color = red>"yes"</font>
end if
do shell script (<font color = red>"defaults write com.apple.dock autohide -bool "</font> & theBool as text)
try
tell application <font color = red>"Dock"</font> to quit
end try</font>[/code]
If you don't have OS X 10.1.2 installed, the statement:
tell app "Terminal" to do script with command
could be used in place of "do shell script", but it launches the terminal to run the commands.
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Jan 27, 2002, 04:12 PM
 
ASM can turn on auto-hiding for specific apps.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 10:05 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2