Macos 在Cocoa中以编程方式向收藏夹添加快捷方式
我已经构建了一个Mac应用程序,我想在安装时在Finder的收藏夹部分添加一个快捷方式。我确实看到其他应用程序实现了同样的功能(比如AirDrop)。如何执行此操作?您可以通过appleScript执行此操作,但这不是最好的方法。(如果将cmd+t更改为其他函数,此操作将失败)Macos 在Cocoa中以编程方式向收藏夹添加快捷方式,macos,cocoa,shortcut,finder,Macos,Cocoa,Shortcut,Finder,我已经构建了一个Mac应用程序,我想在安装时在Finder的收藏夹部分添加一个快捷方式。我确实看到其他应用程序实现了同样的功能(比如AirDrop)。如何执行此操作?您可以通过appleScript执行此操作,但这不是最好的方法。(如果将cmd+t更改为其他函数,此操作将失败) 此外,您还可以使用添加项目。谢谢,这很有用,但这只是添加一个文件夹。没有添加一个外部驱动器,这是我所追求的(对不起,不清楚,我在原来的帖子)。 tell application "Finder" activate
此外,您还可以使用添加项目。谢谢,这很有用,但这只是添加一个文件夹。没有添加一个外部驱动器,这是我所追求的(对不起,不清楚,我在原来的帖子)。
tell application "Finder"
activate
-- Select the path you want on the sidebar in the Finder
select folder "Preferences" of folder "Library" of (path to home folder)
tell application "System Events"
-- Command-T adds the Documents Folder to the sidebar
keystroke "t" using command down
end tell
end tell