【发布时间】:2013-01-11 15:18:21
【问题描述】:
我已经构建了一个 Mac 应用程序,我想在安装时在 Finder 的收藏夹部分中添加一个快捷方式。我确实看到其他应用程序实现了同样的事情(例如 AirDrop)。我该怎么做?
【问题讨论】:
标签: macos cocoa shortcut finder
我已经构建了一个 Mac 应用程序,我想在安装时在 Finder 的收藏夹部分中添加一个快捷方式。我确实看到其他应用程序实现了同样的事情(例如 AirDrop)。我该怎么做?
【问题讨论】:
标签: macos cocoa shortcut finder
你可以通过appleScript来完成,但这不是最好的方法。(如果将cmd+t更改为其他函数,则会失败)
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
另外,您可以使用LSSharedFileList 添加项目。
【讨论】: