get dock location problems in 10.5

I must be having a brain fart because I can’t solve this problem. In 10.5 we now have access to some new “Scriptable System Preferences” as seen here. So I’m trying to find the location of the dock (i.e. bottom, right, or left) using these new capabilities. So I can get the dock preferences like so…

tell application "System Events"
	tell dock preferences
		set dock_props to get properties
	end tell
end tell

But the following doesn’t work so I cannot extract the location from the dock_props. Any thoughts why it doesn’t work or a solution???

tell application "System Events"
	tell dock preferences
		set dock_props to get properties
		set dock_location to location of dock_props
	end tell
end tell

Hi regulus,

this seems to be a bug, same error here
Work around :wink:


tell application "System Events"
	set dock_props to properties of dock preferences
	try
		set dock_location to location of dock_props
	on error e
		set {ASTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "location:"}
		set dock_location to word 1 of text item 2 of e
		set AppleScript's text item delimiters to ASTID
	end try
end tell
dock_location

Parsing the error text!!! That’s slick. I wouldn’t have thought of that. Thanks StefanK! :smiley:

Just as an FYI…
I was trying to use the new capabilities of applescript in 10.5, but you can still get the dock’s location this way:

tell application "System Events"
	set dockProps to property list file "~/Library/Preferences/com.apple.dock.plist"
	set dock_location to the value of the property list item "orientation" of dockProps
end tell

right, but according to System Event’s dictionary it should work just with


tell application "System Events" to set dock_props to location of dock preferences

but doesn’t

Hi guys, this works for me

tell application "System Events" to tell dock preferences to set dock_location to item 3 of (get properties as list) as text