
如何將程式加入 Mac 上的「開啟方式」選單?
答案1
您是指右鍵點選文件時出現的子選單嗎?如果是這樣,它是由啟動服務根據您的應用程式聲稱能夠處理的文件類型自動產生的。如果您查看應用程式套件的內部(右鍵單擊該應用程序,然後選擇「顯示套件內容」),則Contents 資料夾內將有一個Info.plist 文件,其中包含有關該應用程式的各種信息,包括它可以開啟的一系列文件類型(請參閱Apple的開發文檔這裡)。
太長了;如果應用程式處理該類型的文檔,則它應該已經列出;如果沒有,我不知道如何手動添加它。
答案2
答案3
如果您使用腳本編輯器或 Automator 為應用程式製作 Droplet,當您希望將 Droplet 新增至「開啟方式」清單中時,可以執行下列操作:
一如既往,保存您計劃修改的任何應用程式/系統檔案的備份副本!
-- just in case anything goes wrong
從應用程式複製目標檔案副檔名數組是在應用程式的 info.plist 檔案的「開啟方式」清單中列出,並將其貼上到目標應用程式的 info.plist 中的 CFBundleDocumentTypes 數組中(右鍵單擊應用程序,選擇「顯示套件內容」)。在此範例中,我顯示了用資訊檔案中的幾種檔案類型
VLC droplet.app
取代通配符副檔名 (" ") 資料後資訊檔案的前後情況:*
VLC.app
"/Applications/VLC droplet.app/Contents/Info.plist"
:
前:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>*</string>
</array>
<key>CFBundleTypeOSTypes</key>
<array>
<string>****</string>
</array>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
</array>
後:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFile</key>
<string>aiff.icns</string>
<key>CFBundleTypeName</key>
<string>AIFF file</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSItemContentTypes</key>
<array>
<string>public.aiff-audio</string>
<string>public.aifc-audio</string>
</array>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>divx</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>movie.icns</string>
<key>CFBundleTypeName</key>
<string>DivX file</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
<dict>
<key>CFBundleTypeIconFile</key>
<string>m4v.icns</string>
<key>CFBundleTypeName</key>
<string>MPEG-4 File</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSItemContentTypes</key>
<array>
<string>public.mpeg-4-audio</string>
<string>com.apple.m4v-video</string>
<string>public.mpeg-4</string>
</array>
</dict>
</array>
- 開啟終端,然後輸入以下命令,變更
<TARGET_APP>
為您正在編輯 info.plist 的應用程式的名稱,以將其新增至「開啟方式」清單:
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -f "/Applications/<TARGET_APP>.app/"
- 輸入指令
killall Finder
強制重新啟動 Finder。
如果應用程式已簽名,則修改 Info.plist使程式碼簽名無效。它還導致 TextEdit 和 WriteRoom 等一些應用程式在 10.8 上啟動時崩潰。
注意:我獲取了此答案的一些資訊並對其進行了編輯以使用更詳細的資訊/解釋進行更新。原始線程位於這裡。