2

我已经构建了一个 Mac 应用程序,我想在安装时在 Finder 的收藏夹部分中添加一个快捷方式。我确实看到其他应用程序实现了同样的事情(例如 AirDrop)。我该怎么做呢?

4

1 回答 1

0

您可以通过 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添加项目。

于 2013-01-11T17:39:34.640 回答