changing the Dock with Automator?

I don't know Automator at all and I'm quite certain I don't want to learn it (old dog/new tricks). However, I have a simple task I'd like to 'program' as a key combination command. I want to be able to change the Dock's appearance and location (dependent upon application). I've looked at Automator ('brain glazed over') and browsed for a solution to no avail. I do know how to change the Dock's appearance in System Preferences but would rather have one key command rather than 6 to 8 steps to toggle between desired settings. Would anyone know how to do this with Automator (or otherwise)?

MacMini (and others), Mac OS X (10.4.6)

Posted on Dec 4, 2006 3:47 PM

Reply
5 replies

Dec 6, 2006 8:30 PM in response to Mark McMurtry

Mark,

I am working on a couple of solutions but need a little more information. I have worked out a method for location but was wondering which of the appearance features are you interested in? Are you currently using a key assignment program like Spark, QuicKeys or iKey?

Solution 1: Use an key assignment program to assign a key combination command(s) to AppleScripts that I have developed.

Solution 2: Use a faceless program to monitor which application is frontmost and then modify the Dock automatically to match assigned property values in an AppleScript.

Dec 6, 2006 8:51 PM in response to lc55

well thanks for your response and trouble

However, quite by accident - about 5 minutes before receiving your reply email notification - I learned that there already is a predefined keyboard shortcut to hide/show the Dock. It's Option, Command (apple), D" I also wanted to move it from horizontal to vertical on right when using PhotoShop, Vectorworks or other graphics Apps and have on the bottom with all other apps and internet. There isn't a keyboard shortcut for that to my knowledge. If that is something Automator could do with a key/function shortcut, them I'm still interested in that.

Thanks for your interest.


MacMini (and others) Mac OS X (10.4.6)

Dec 8, 2006 8:42 AM in response to Mark McMurtry

Just in case you are interested here are the previously worked out solutions which actually give you almost complete control over the Dock.

1) An AppleScript that can be triggered by a hot key. This is actually a single AppleScript that detects whether the frontmost application is one of the graphics apps or not. You can create hot keys using any number of applications, some free (e.g. Spark, FScript Lite) others you need to pay
(QuicKeys, iKeys, FScript), and then attach this AppleScript to that hot key.

click here to open this script in your editor <pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px">property GraphicsApps : {"GraphicConverter", "MacDraft"} -- applications to apply graphics dock settings
property CurrentTypeOfDockSettings : "" -- "Graphics" and "Default" current options
property ListOfDockSettings : {"pinning", "orientation", "magnification", "autohide", "tilesize", "largesize", "mineffect", "launchanim"}

(*
ListOfDockSettings has following available options:
1) pinning_value {"start", "center", "end"}
2) orientation_value {"top", "bottom", "left", "right"}
3) magnification {true, false}
4) autohide {true, false}
5) tile_size {16-128}
6) magnification largesize {16-128}
7) minimize_effect {"scale","genie"}
8) launch_animation {true, false}
*)

property GraphicsAppsDockSettings : {"start", "right", false, true, 32, 32, "scale", true}
property DefaultDockSettings : {"center", "bottom", true, false, 64, 128, "genie", true}

on run {}
tell application "System Events" to set FrontmostProcess to (name of every process whose frontmost is true) as text
if (GraphicsApps contains FrontmostProcess) then -- frontmost app a graphics app
if (CurrentTypeOfDockSettings is not equal to "Graphics") then -- Dock not already set with graphics properties
my ChangeDockSettings(GraphicsAppsDockSettings)
set CurrentTypeOfDockSettings to "Graphics"
end if
else -- frontmost app not a graphics app
if (CurrentTypeOfDockSettings is not equal to "Default") then -- Dock not already set with default properties
my ChangeDockSettings(DefaultDockSettings)
set CurrentTypeOfDockSettings to "Default"
end if
end if
end run

on ChangeDockSettings(DockSettings)
tell application "System Events"
set UsersHomeDirectory to (POSIX file (home directory of current user)) as text
set Dockplist to property list file (UsersHomeDirectory & "Library:Preferences:com.apple.dock.plist")
repeat with i from 1 to count of ListOfDockSettings
set ((value of property list items of Dockplist) whose name is item i of ListOfDockSettings) to item i of DockSettings
end repeat
do shell script "/usr/bin/killall Dock" -- restart the Dock
end tell
end ChangeDockSettings</pre>

2) An AppleScript application that runs in the background and detects the frontmost application and then adjusts the Dock accordingly. You will notice that there isn't much difference in the code but this one must be saved as a stay-open application (in typical programming humour I have called mine "Witch Dockter?"). You run it like an ordinary application and it will automatically change the Dock between graphic apps and the others.

click here to open this script in your editor <pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px">property GraphicsApps : {"GraphicConverter", "MacDraft"} -- applications to apply graphics dock settings
property CurrentTypeOfDockSettings : "" -- "Graphics" and "Default" current options
property PollingTime : 5 -- time between detecting frontmost application in seconds
property ListOfDockSettings : {"pinning", "orientation", "magnification", "autohide", "tilesize", "largesize", "mineffect", "launchanim"}

(*
ListOfDockSettings has following available options:
1) pinning_value {"start", "center", "end"}
2) orientation_value {"top", "bottom", "left", "right"}
3) magnification {true, false}
4) autohide {true, false}
5) tile_size {16-128}
6) magnification largesize {16-128}
7) minimize_effect {"scale","genie"}
8) launch_animation {true, false}
*)

property GraphicsAppsDockSettings : {"start", "right", false, true, 32, 32, "scale", true}
property DefaultDockSettings : {"center", "bottom", true, false, 64, 128, "genie", true}

on idle {}
tell application "System Events" to set FrontmostProcess to (name of every process whose frontmost is true) as text
if (GraphicsApps contains FrontmostProcess) then -- frontmost app a graphics app
if (CurrentTypeOfDockSettings is not equal to "Graphics") then -- Dock not already set with graphics properties
my ChangeDockSettings(GraphicsAppsDockSettings)
set CurrentTypeOfDockSettings to "Graphics"
end if
else -- frontmost app not a graphics app
if (CurrentTypeOfDockSettings is not equal to "Default") then -- Dock not already set with default properties
my ChangeDockSettings(DefaultDockSettings)
set CurrentTypeOfDockSettings to "Default"
end if
end if
return PollingTime
end idle

on ChangeDockSettings(DockSettings)
tell application "System Events"
set UsersHomeDirectory to (POSIX file (home directory of current user)) as text
set Dockplist to property list file (UsersHomeDirectory & "Library:Preferences:com.apple.dock.plist")
repeat with i from 1 to count of ListOfDockSettings
set ((value of property list items of Dockplist) whose name is item i of ListOfDockSettings) to item i of DockSettings
end repeat
do shell script "/usr/bin/killall Dock" -- restart the Dock
end tell
end ChangeDockSettings</pre>

NOTES:

1) In both cases you have to decide which applications you want the graphics Dock by setting the GraphicsApps property to a list of the names of those applications. Just change the names shown to what you require.

2) You will have to decide the values for the Dock properties (GraphicsAppsDockSettings & DefaultDockSettings) from the complete List Of Dock Settings indicated in the script. I just put in some interesting values for testing purposes.

Let me know if you need any help with either of these.

PowerBook 12" Mac OS X (10.4.8)

Dec 8, 2006 3:42 PM in response to lc55

Wow! thanks for your detailed efforts. Regretably, although I understand the concepts you presented, I've NEVER written/used Applescript or messed with the Editor in OSX. Therefore, I have little to no confidence I could pull either off without screwing something significant up. I've saved a copy of you response to disk and may get the courage to experiment in due coarse (e.g. once the dock gets in my way once too many times).

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

changing the Dock with Automator?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.