Using this Prefab UI utility to help me create the script (
available here), this is what I've come up with (this example is my "Home" script):
Code:
activate application "Finder"
tell application "System Events"
get system attribute "sysv"
if result is greater than or equal to 4144 then -- Mac OS X 10.3.0
if UI elements enabled then
tell application process "Finder"
-- GUI Scripting statements:
click menu item "Position on Right" of menu 1 of menu item "Dock" of menu 1 of menu bar item "Apple" of menu bar 1
end tell
else
beep
display dialog "GUI Scripting is not enabled" & return & return & "Open System Preferences and check Enable Access for Assistive Devices in the Universal Access preference pane, then run this script again." with icon stop
if button returned of result is "OK" then
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.universalaccess"
end tell
end if
end if
else
beep
display dialog "This computer cannot run this script" & return & return & "The script uses GUI Scripting technology, which requires an upgrade to Mac OS X 10.3 Panther or newer." with icon caution buttons {"Quit"} default button "Quit"
end if
end tell
do shell script "scselect Home"
How to improve this?
(a) I know that a lot of the stuff in the AppleScript is needless.
(b) Perhaps making it so that when I run the script a pop-up asks me which location I'd like to use [only one script needed in scripts menu].
(c) Perhaps having the applescript recognize which I'm using and just switch to the other one [only one script needed in scripts menu].
(d) Finding a way that doesn't require the switch to Finder to change the dock.
The main advantage to this version is that it doesn't require the opening of System Preferences.
Thanks again...