MacOS – AppleEvent Handler failed (-10000)

applescriptdockmacos

I'm having issues with a simple part of script, where I wanna get the property dock preferences of System Events. I have the following:

tell application "System Events"
    tell appearance preferences
        set ap_prefs to (get the properties)
        set ap_prefs to the properties
    end tell
    set a_pref to the properties of appearance preferences

    tell dock preferences
        set d_prefs to (get the properties)
    end tell
    set d_pref to the properties of dock preferences
end tell

In the code above I access appearance preferences in all the ways shown above, but not dock preferences. It give an error error "System Events got an error: AppleEvent handler failed." number -10000.

So what is going on, and why is only giving error with dock? Here @dj_bazzie_wazzie says:

Error -10000…most of the time it is not a target error but an incomplete command or wrong usage of brackets.

But I can't figure out what is the proper way. I've tried all I can think of, also why doesn't it throw the exception for appearance preferences?

Cheers

I've also opened this question on Stack Overflow, I'll close one when I get a answer.

Best Answer

This works for me in the latest version of macOS Sierra...

tell application "System Events"
    set dockPrefs to dock preferences
    set appearancePrefs to appearance preferences
end tell