Find My (Apple)
在 macOS 上透過 FindMy.app 追蹤 Apple 裝置與 AirTag。由於 Apple 沒有為 Find My 提供命令列介面,此技能使用 AppleScript 來開啟應用程式,並以螢幕擷取功能讀取裝置位置。
必要條件
- macOS:需安裝 Find My 應用程式並登入 iCloud
- 裝置 / AirTag 已預先註冊在 Find My 中
- 終端機的「螢幕錄製」權限(系統設定 → 隱私權與安全性 → 螢幕錄製)
- 建議安裝:
peekaboo可獲得更好的 UI 自動化效果:brew install steipete/tap/peekaboo
使用時機
- 使用者詢問「我的 [裝置/貓/鑰匙/背包] 在哪裡?」
- 追蹤 AirTag 位置
- 檢查裝置位置(iPhone、iPad、Mac、AirPods)
- 長時間監控寵物或物品的移動(AirTag 巡邏路線)
方法一:AppleScript + 螢幕截圖(基本)
開啟 FindMy 並導航
# 開啟 Find My 應用程式
osascript -e 'tell application "FindMy" to activate'
# 等待載入
sleep 3
# 擷取 Find My 視窗畫面
screencapture -w -o /tmp/findmy.png
然後使用 vision_analyze 來讀取螢幕截圖:
vision_analyze(image_url="/tmp/findmy.png", question="畫面中顯示哪些裝置/物品及其位置?")
切換分頁
# 切換到裝置分頁
osascript -e '
tell application "System Events"
tell process "FindMy"
click button "Devices" of toolbar 1 of window 1
end tell
end tell'
# 切換到物品分頁(AirTag)
osascript -e '
tell application "System Events"
tell process "FindMy"
click button "Items" of toolbar 1 of window 1
end tell
end tell'
方法二:Peekaboo UI 自動化(建議)
如果安裝了 peekaboo,可用它進行更可靠的 UI 互動:
# 開啟 Find My
osascript -e 'tell application "FindMy" to activate'
sleep 3
# 擷取並標註 UI
peekaboo see --app "FindMy" --annotate --path /tmp/findmy-ui.png
# 按元素 ID 點選特定裝置/物品
peekaboo click --on B3 --app "FindMy"
# 擷取詳細檢視
peekaboo image --app "FindMy" --path /tmp/findmy-detail.png
然後用視覺分析:
vision_analyze(image_url="/tmp/findmy-detail.png", question="此裝置/物品顯示的位置為何?請包含地址與座標(若可見)")
工作流程:長時間追蹤 AirTag 位置
用於監控 AirTag(例如追蹤貓的巡邏路線):
# 1. 開啟 FindMy 到物品分頁
osascript -e 'tell application "FindMy" to activate'
sleep 3
# 2. 點選該 AirTag 物品(保持頁面開啟 — AirTag 僅在頁面開啟時更新位置)
# 3. 定期擷取位置
while true; do
screencapture -w -o /tmp/findmy-$(date +%H%M%S).png
sleep 300 # 每 5 分鐘
done
用視覺分析每張螢幕截圖以提取座標,然後編譯路線。
限制
- Find My 沒有命令列或 API — 必須使用 UI 自動化
- AirTag 僅在 Find My 頁面保持顯示時才會更新位置
- 位置準確度取決於 Find My 網路中附近 Apple 裝置的數量
- 需要「螢幕錄製」權限才能進行螢幕擷取
- AppleScript UI 自動化可能因 macOS 版本更新而失效
規則
- 追蹤 AirTag 時讓 FindMy 應用程式保持在前景(最小化時更新會停止)
- 使用
vision_analyze讀取螢幕截圖內容 — 不要嘗試解析像素 - 進行長時間追蹤時,使用 cron 定時任務定期擷取並記錄位置
- 尊重隱私 — 僅追蹤使用者擁有的裝置/物品