我正在嘗試使用 applescript 讀取請勿打擾或 dnd 的狀態。
出于某種原因,無論 dnd 是打開還是關閉,它總是回傳“1”。
do shell script "defaults -currentHost read ~/Library/Preferences/ByHost/com.apple.notificationcenterui doNotDisturb"
堆疊編輯器:用于創建和運行腳本的腳本編輯器作業系統:macOS Monterey
uj5u.com熱心網友回復:
如果您不介意通過 Mac OS Monterey 上的 UI 閱讀它
log getDNDStatus()
on getDNDStatus()
set currentState to 1
tell application "System Events" to tell process "ControlCenter"
click of menu bar item "Control Center" of menu bar 1
if exists (first checkbox of front window whose title is "Focus") then set currentState to 0
end tell
tell application "System Events" to key code 53 -- Escape to close the control center popup
currentState
end getDNDStatus
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/457651.html
上一篇:js中,迭代和遍歷的區別
