GUI Scripting - click using modifier?

GUI Scripting allows a keystroke using modifier keys, but is there a way to click using modifier keys?

In particular, I’m trying to option-click an item.

I think you can hold the option key down this way:

tell application "System Events"
	key down option
	-- do your click however you do it
	key up option
end tell

Thanks for the suggestion!

Although it didn’t work. The click occurred the same as if I didn’t include the key down part.

Essentially what I’m trying to do is get Safari to simulate an option-click on a hyperlink, forcing it to download the linked file (the reason I’m doing this is because that is the only download method I’ve found that preserves the file’s original creation and modification dates). Here’s my code:

tell application "Safari" to activate
tell application "System Events"
	tell process "Safari"
		key down option
		click static text "click" of UI element "click" of group 1 of UI element 1 of scroll area 1 of group 3 of window "page.html"
		key up option
	end tell
end tell

You might be better off then using JavaScript from your AppleScript. Without knowing what you are trying to click, I can’t say more.

I figured out a better solution anyway, using curl’s -R argument. It’s a shame that option isn’t featured by many (any) browsers.

This no longer seems to work for me in Mojave:


tell application "System Events"
	tell application process "SystemUIServer"
		key down option
		click menu bar item "Notification Center" of menu bar 1
		key up option
	end tell
end tell

The Notification Center button just gets a normal click. Any ideas?

Model: MacBook Pro
AppleScript: 2.11 (203)
Browser: Safari 605.1.15
Operating System: macOS 10.14