Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos Applescript:执行上下文菜单操作_Macos_Applescript_Finder - Fatal编程技术网

Macos Applescript:执行上下文菜单操作

Macos Applescript:执行上下文菜单操作,macos,applescript,finder,Macos,Applescript,Finder,很抱歉,我想不出更好的标题了。 我制作了一个小的applescript服务,它获取您在Finder中选择的文件的unix路径,然后将该路径存储在剪贴板中。 我使用这个文件是在我的谷歌驱动器卷,现在我想添加一个额外的功能,这是由谷歌驱动器文件流应用程序的支持 如果我右键点击finder中的Google Drive文件,我会在上下文菜单中获得3个额外的项目,请参见附件中的屏幕截图。 我只想让我的脚本运行“复制链接到剪贴板” 那么,我该如何告诉苹果脚本这样做呢? 我很抱歉这个非常琐碎的问题,但我认为我

很抱歉,我想不出更好的标题了。 我制作了一个小的applescript服务,它获取您在Finder中选择的文件的unix路径,然后将该路径存储在剪贴板中。 我使用这个文件是在我的谷歌驱动器卷,现在我想添加一个额外的功能,这是由谷歌驱动器文件流应用程序的支持

如果我右键点击finder中的Google Drive文件,我会在上下文菜单中获得3个额外的项目,请参见附件中的屏幕截图。 我只想让我的脚本运行“复制链接到剪贴板”

那么,我该如何告诉苹果脚本这样做呢? 我很抱歉这个非常琐碎的问题,但我认为我缺乏正确的术语来进行谷歌搜索,我所能找到的只是如何在上下文菜单中添加一个苹果脚本,我已经这样做了


使用
AXShowMenu
打开关联菜单。然后发送按键“复制链接到剪贴板”以选择复制操作,并发送“回车”以激活该操作

tell application "System Events" to tell application process "Finder"
    set selectedFile to value of attribute "AXFocusedUIElement"
    tell selectedFile to perform action "AXShowMenu"
    delay 0.5
    keystroke "Copy link to clipboard"
    -- Sends enter
    key code 36
end tell
请注意,当使用Finder的图标视图时,此功能无法正常工作。必须使用列表视图或列视图