2013-01-11 96 views
2

我已经构建了一个Mac App,并且我想在安装时在Finder的收藏夹部分添加一个快捷方式。我找不到有关如何做到这一点的文档,但我确实看到其他应用程序实现相同的功能(例如AirDrop)。有没有人有任何想法如何做到这一点?在Cocoa/XCode中以编程方式添加快捷方式

回答

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

+0

THanks,这很有用,但这只是添加一个文件夹。没有增加一个外部驱动器,这是我以后(对不起,我不知道原来的帖子)。 – user1970393

+0

外部驱动器???? –

相关问题