
























macOS 的“关闭窗口 ≠ 退出应用”逻辑,对于强迫症或者刚转系统的朋友来说真的很难受!😫 每次都要 Cmd+Q ,不然 Dock 栏永远一堆小白点。 作为一名喜欢折腾的前端工程师 👨💻,我写了一个 BetterTouchTool (BTT) 脚本,完美实现了“点击红叉 = 退出应用”,而且比网上的普通脚本更智能!
-- 配置你的“保活”应用名单
set keepAliveApps to {"WeChat", "Telegram", "Spotify", "Music", "DingTalk"}
tell application "System Events"
set frontApp to first application process whose frontmost is true
set appName to name of frontApp
-- 白名单检查:如果是常驻应用,只关闭不退出
if keepAliveApps contains appName then
keystroke "w" using command down
return
end if
-- 获取窗口类型,防止误关设置弹窗
try
set currentSubrole to subrole of front window of frontApp
on error
set currentSubrole to "Unknown"
end try
set standardWindowCount to count of (windows of frontApp where subrole is "AXStandardWindow")
end tell
-- 逻辑判断
if currentSubrole is not "AXStandardWindow" then
tell application "System Events" to keystroke "w" using command down
return
end if
if standardWindowCount is less than or equal to 1 then
tell application appName to quit
else
tell application "System Events" to keystroke "w" using command down
end if
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。