使用 applescript 隐藏所有应用程序

发布于 2025-01-12 05:13:08 字数 360 浏览 2 评论 0原文

我正在尝试使用 applescript 来隐藏所有打开的应用程序。

tell application "System Events"
    set visible of every process whose visible is true and name is not "Finder" to false
end tell

不幸的是它没有按预期工作。

  • 我第一次运行它时,它隐藏脚本编辑器,但不隐藏其他应用程序
  • 第二次或第三次运行它时,它关闭脚本编辑器和其他应用程序(但不是查找窗口)

我的目标是一旦 applescript 运行,隐藏所有应用程序正在运行的应用程序

I am trying to work on an applescript to hide all apps that are open.

tell application "System Events"
    set visible of every process whose visible is true and name is not "Finder" to false
end tell

Unfortunately it is not working as expected.

  • The first time when I run it, it hides script editor but not other apps
  • The second or third time when I run it, it closes script editor and other apps(but not finder windows)

My goal is as soon as applescript runs, hide all apps that are running

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

末骤雨初歇 2025-01-19 05:13:08

根据 Willeke 的说法,这对我有用:

tell application "System Events"
    set visibleApps to every process whose visible is true and name is not "Finder"
    repeat with theApp in visibleApps
        set visible of theApp to false
    end repeat
end tell

according to Willeke, this works for me :

tell application "System Events"
    set visibleApps to every process whose visible is true and name is not "Finder"
    repeat with theApp in visibleApps
        set visible of theApp to false
    end repeat
end tell
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文