Alfred使用AppleScript来实现一键隐藏功能(老板键)


更新:
2024.04.15 如果某个进程不判断捕获异常,使得代码能够继续执行
set appNames to { "WeChat", "QQ"}
tell application "System Events"
repeat with appName in appNames
try
set appProcess to first process whose name is appName
set appId to id of appProcess
tell process appName
set visible to false
end tell
on error errMsg
-- Ignore error if process does not exist
end try
end repeat
end tell
set appNames to {"WeChat","QQ"} -- 将要隐藏的进程名称放入数组中
tell application "System Events"
repeat with appName in appNames
set appProcess to first process whose name is appName
set appId to id of appProcess
tell process appName
set visible to false
end tell
end repeat
end tell

浙公网安备 33010602011771号