開發人員適用
Switchbar API
Switchbar 提供以 URL 為基礎的 API。開啟一個特別格式化的 URL,Switchbar 就會立即開始運作——將連結傳送到正確的瀏覽器或電子郵件客戶端,或提示你選擇一個。
運作方式
switchbar://open/<link>網頁和電子郵件連結
可傳入任何
https://、http://或mailto:連結。套用您的規則
連結會像點擊一樣經過您的規則和連結設定。如果沒有符合的規則,Switchbar 會詢問要在哪裡開啟。
無需編碼
在
switchbar://open/後直接加上連結,無需進行百分比編碼。
範例
Terminal
# macOS
open "switchbar://open/https://example.com"
open "switchbar://open/mailto:hello@example.com"
# Windows
start "" "switchbar://open/https://example.com"AppleScript
open location "switchbar://open/https://example.com"JavaScript
window.location.href = "switchbar://open/https://example.com";Swift
let url = URL(string: "switchbar://open/https://example.com")!
NSWorkspace.shared.open(url)相容 Choosy URL
Switchbar 也能開啟 Choosy API 連結,為 Choosy 撰寫的指令碼和工具無需修改即可使用。
x-choosy://open/
x-choosy://prompt.all/
x-choosy://prompt.running/
x-choosy://best.all/
x-choosy://best.running/