Dock size without UI Elements

This code gets you the width and height of the current dock.
Does anyone know how to get this without having to enable Assistive Devices in Sys Prefs?
Thanks.

tell application "System Events" to tell first UI element of application process "Dock" to set {dockWidth, dockHeight} to size
-- error "System Events got an error: AppleScript Editor is not allowed assistive access." number -1719 from UI element 1 of application process "Dock"

This works in Snow Leopard:

set prefsFile to ((path to preferences from user domain) as text) & "com.apple.dock.plist"
tell application "System Events"
	set dockSize to (value of property list item "tilesize" of property list file prefsFile)
end tell

Tilesize is the only relevant key in the plist; no dockWidth, dockHeight, or equivalent.

Thanks for that alastor933,

Your code works in Mavericks in AppleScript Editor 2.6(1.5.2) AppleScript 2.3

I observed:
The dock on the left and the right does not change its size for me when I change all the way from small to big (maybe because I have too many apps icons in it)
The bottom has more room and it does.

I am familiar with the tileSize. It changes with the size that you assign to the dock but unfortunately it does not reflect its real height in pixels from the bottom of the screen.

If you run my code and yours on the same size you will see the difference.
In my tests tileSize goes from 16 to 128 but in reality it only goes (in my dock’s case) from 30 to 35 pixels at each end of the scale.

I believe tileSize might be the max amount allocated to the dock at any given setting of the size slider in Sys Prefs, but it is then reduced as you keep adding icons to it.
You can see it very large when you do a new install of the System software but as you add apps it grows longer and thinner.

What a strange animal the dock! :slight_smile: