问题
How can I control click with AppleScript?
This script should work, but it doesn't
activate application "Finder"
tell application "System Events"
tell process "Finder"
key down control
delay 1
click at {600, 600} -- {from left, from top}
delay 1
key up control
end tell
end tell
MouseTools is sometimes unreliable. I know of cliclick — still haven't tried it.
I'd prefer an AS only workaround but welcome any suggestions.
回答1:
- Most of the actions from contextual menu you can do using menu bar (File, Edit, etc.). It can simplify your job.
- To open contextual menu for particular GUI element you should tell to
perform action "AXShowMenu"to that element. You can use Accessibility Inspector application to find out the GUI elements hierarchy. Take a look at this discussion. - You can try mouse keys. Take a look at this thread for details. Note that "Mouse Keys" settings is in the "System Preferences" -> "Accessibility" -> "Mouse & Trackpad" in Mountain Lion.
- For finder scripting AppleScript Finder Guide can be of much help.
来源:https://stackoverflow.com/questions/15987881/applescript-control-click