MacOS – Bring all windows of active application to top

macoswindow-manager

When switching to an application (cmd+tab or clicking on an app icon), osx brings all of the application's windows to top.

I would like to trigger this behaviour for the active application with some shortcut, or most preferably triggered when clicking the dock icon of the active application. (Currently clicking on the dock icon of an active app switches to the next workspace that has a window of the app.)

Is there a way to bring to top all windows of the active application?

EDIT: Seems there's a Window -> Bring All to Front action that does this. Now I only need a way to trigger this action, preferably when the app icon in the dock is clicked.

Third party command solutions (e.g. some simple keyboard shortcut app to run the Bring All to Front action) are welcome, though I'd prefer a native way of doing this.

Best Answer

You can assign a keyboard shortcut to the "Bring All to Front" menu item from System Preferences:

The activate AppleScript command also raises all windows:

activate application (path to frontmost application as text)

If you are assigning keyboard shortcuts to opening applications, you can use scripts like this:

tell application "TextEdit"
    reopen
    activate
end tell

reopen opens a new default window if there are no open "default" windows, like a text editor window in TextEdit. If all default windows are minimized, reopen unminimizes one of them.

It is also possible to use AppleScript to click the "Bring All to Front" menu item:

tell application "System Events" to tell (process 1 where frontmost is true)
    click menu item "Bring All to Front" of menu 1 of menu bar item "Window" of menu bar 1
end tell