Build keyboard shortcut for "minimize all windows of current app except the current window" I'm looking to bind a keyboard shortcut to the action &quot;minimize all windows from the current application except the current window.&quot; (The app in question is always Google Chrome.)
(Sort of like ⌘ + ⌥ + h, which translates to &quot;hide all applications except the current application&quot;.)
I've never bound a new shortcut, but I suspect I could figure it out once I have a working AppleScript for the task. I also use Better Touch Tool, in case it is easier to go through that app.
This question asks the same thing, but the answers are not bindable to a simple keyboard shortcut as far as I can tell.
This question asks the same thing (except specifically for Safari), and a user suggests the AppleScript
tell application &quot;Safari&quot;
    activate
    tell application &quot;System Events&quot;
        keystroke &quot;h&quot; using {command down, option down}
    end tell
    set miniaturized of (windows whose index is not 1) to true
end tell

When I replace &quot;Safari&quot; with &quot;Google Chrome&quot; in the script, and try to run it from Script Editor, I get the error
Script error: Google Chrome got an error: Can’t make miniaturized of every window whose index ≠ 1 into type specifier.

Can anyone help? Thanks
The following example AppleScript code will minimize all but the front window in Google Chrome:
tell application &quot;System Events&quot; to ¬
    set miniaturized of windows of application ¬
        &quot;Google Chrome&quot; whose index is not equal to 1 to true

Since you already have BetterTouchTool and assuming it can run AppleScript code or an AppleScript .scrpt file with a keyboard shortcut, that is probably the easiest way to go to trigger the code.
That said, my preferred method for running AppleScript scripts with a keyboard shortcut, is to use a third-party application named FastScripts, however you can also use Automator with a Run AppleScript action as a Service/Quick Action and assign it a keyboard shortcut in: System Preferences &gt; Keyboard &gt; Shortcuts &gt; Services

The keyboard shortcut assigned to the Service/Quick Action needs to not conflict with a default keyboard shortcut for whichever application is frontmost at 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.