Open context menu of a Dock icon

This doesn’t work:

tell application "System Events" to tell process "Dock"
	key down control
	click UI element "System Preferences" of list 1
	key up control
end tell

I thought about just assigning the script a shortcut that uses ⌃ as a modifier, but the click command seems to ignore modifier keys held down by the user.

Hi,

try this


tell application "System Events" to tell process "Dock"
	perform action "AXShowMenu" of UI element "System Preferences" of list 1
end tell