Applescript右键单击一个文件

Jam*_*mes 5 macos applescript

苹果脚本中是否有命令右键单击文件并调出上下文菜单?

我正在寻找类似的东西

tell application "Finder"
    set theDesktopItems to every item of desktop
    right click item 1 of theDesktopItems
end tell
Run Code Online (Sandbox Code Playgroud)

ada*_*amh 7

这是System Events应用程序的一项工作.它可用于在大多数应用程序中访问菜单项及其操作,甚至是那些不能编写脚本的应用程序.

试试这个:

tell application "System Events"
    tell process "Finder"
        set target_index to 1
        set target to image target_index of group 1 of scroll area 1
        tell target to perform action "AXShowMenu"
    end tell
end tell
Run Code Online (Sandbox Code Playgroud)

如果您愿意,请查看此链接以获取有关使用系统事件的概述:http://n8henrie.com/2013/03/a-strategy-for-ui-scripting-in-applescript/