首页>Apple>source

我希望将键盘快捷键绑定到动作"最小化当前应用程序中除当前窗口之外的所有窗口". (有问题的应用始终是Google Chrome浏览器。)

(像 ⌘ + ⌥ + h的排序 ,翻译为"隐藏当前应用程序以外的所有应用程序"。)

我从来没有绑定过一个新的快捷方式,但是我怀疑一旦我有一个适用于该任务的AppleScript,就可以弄清楚.如果要更轻松地浏览该应用程序,我还会使用Better Touch Tool。

这个问题问的是同一件事,但答案不具有约束力 据我所知,它只是一个简单的键盘快捷键。

问题问 同样的东西(除了Safari专用),并且用户建议使用AppleScript

tell application "Safari"
    activate
    tell application "System Events"
        keystroke "h" using {command down, option down}
    end tell
    set miniaturized of (windows whose index is not 1) to true
end tell

当我在脚本中用" Google Chrome"替换" Safari"并尝试从脚本编辑器运行时,出现错误

Script error: Google Chrome got an error: Can’t make miniaturized of every window whose index ≠ 1 into type specifier.

有人可以帮忙吗? 谢谢

最新回答
  • 2021-1-5
    1 #

    以下示例 AppleScript code将最小化 Google Chrome中除窗口之外的所有内容 :

    tell application "System Events" to ¬
        set miniaturized of windows of application ¬
            "Google Chrome" whose index is not equal to 1 to true
    

    因为您已经有了 BetterTouchTool 并假设它可以运行 AppleScript codeAppleScript .scrpt 文件快捷键,这可能是触发code的最简单方法。

    也就是说,我运行 AppleScript的首选方法 脚本快捷键,用于使用名为 FastScripts第三方应用程序 ,但是您也可以使用 Automator 与一个 Run AppleScript action作为Service / Quick Action,并将其分配给键盘快捷键,网址为: System Preferences > Keyboard > Shortcuts > Services

      Thekeyboard shortcutassigned to theService/Quick Actionneeds to not conflict with a defaultkeyboard shortcutfor whicheverapplicationisfrontmostat the time it's pressed, otherwise there may be unwanted behavior.


      FastScripts can be run as a free app, up to 10 keyboard shortcuts, or upgraded for $24.95 USD to unlock unlimited keyboard shortcuts. I have no affiliation with Red Sweater Software, LLC, other then as a user of FastScripts.

  • imac:我的Mac的用户界面全天随机冻结5-10秒我如何找出问题所在?
  • USB C cable for MacBook Pro 2019 16":适用于MacBook Pro 2019 16英寸的USB-C电缆-完全支持的充电电缆吗?