Applescript 暴露所有 Finder 窗口?

发布于 2024-11-30 09:34:02 字数 503 浏览 0 评论 0原文

我正在尝试弄清楚如何编写一个 Applescript 来公开所有 Finder 窗口。

应用程序逻辑

我认为脚本需要有这样的应用程序逻辑:

  • 检查剩余设置并获取最后一个“Frontmost”的名称 Application”(也许使用文本文件 ~/last-application.txt 来存储它?)
  • 获取当前最前端应用程序的名称
  • 如果当前最前端应用程序的名称是 Expose,则激活前一个最前端应用程序
  • 否则,激活 当脚本被激活

所需的行为

  • 时,所有的查找器窗口(并且仅查找器窗口)将显示在 Exposé 中
  • 如果然后再次运行脚本(并且没有选择查找器窗口)脚本只会切换回最后一个最前面的应用程序,

我不确定如何使其工作。如果有另一个实用程序可以自动执行此操作,那也很棒。

但 .net/4luoo.png" alt="在此处输入图像描述">

I'm trying to figure out how to write an Applescript that will Exposé all Finder Windows.

Application Logic

I think the script needs to have this application logic:

  • Check a residual setting and get the name of the last "Frontmost
    Application" (perhaps use a text file ~/last-application.txt to store this?)
  • Grab the name of the current Frontmost Application
  • If the name of the current of the Frontmost Application is Expose, then activate the previous frontmost application
  • Else, activate finder, and then activate expose for just finder windows

Desired Behavior

  • When the script is activated all the finder windows (and only the finder windows) will be shown in Exposé
  • If the script is then run again (and no finder window was selected) the script will just switch back to the last frontmost application

I'm not sure how to get this working though. If there is another utility that does this automatically that'd be great, too.

enter image description here

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

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

发布评论

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

评论(1

蓝颜夕 2024-12-07 09:34:02
set f to "/s/x/finderexpose"
set prev to do shell script "touch " & f & "; cat " & f
if prev is not "" then
    delay 0.5 -- time to release modifier keys used in a shortcut
    tell application "System Events" to key code 53 -- esc, if Exposé is open
    delay 0.3 -- for the Exposé animation?
    activate application prev
    do shell script "echo '' > " & f
else
    do shell script "echo " & quoted form of (path to frontmost application as text) & " > " & f
    activate application "Finder"
    delay 0.05
    tell application "System Events" to key code 125 using {control down} -- ⌃↓
end if

如果省略切换到上一个应用程序的部分,那就不会那么难看了:

activate application "Finder"
delay 0.05
tell application "System Events" to key code 125 using {control down}
set f to "/s/x/finderexpose"
set prev to do shell script "touch " & f & "; cat " & f
if prev is not "" then
    delay 0.5 -- time to release modifier keys used in a shortcut
    tell application "System Events" to key code 53 -- esc, if Exposé is open
    delay 0.3 -- for the Exposé animation?
    activate application prev
    do shell script "echo '' > " & f
else
    do shell script "echo " & quoted form of (path to frontmost application as text) & " > " & f
    activate application "Finder"
    delay 0.05
    tell application "System Events" to key code 125 using {control down} -- ⌃↓
end if

It'd be less ugly if the part for switching to the previous application was left out:

activate application "Finder"
delay 0.05
tell application "System Events" to key code 125 using {control down}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文