Is there a shortcut or such to send the currently active window to the back of the screen while still keeping it open (so that it ends up "beneath" all other open windows)?
-
2H will send the current app (inc all its windows) to the back and hide it until you bring it back to the front (from the dock or by -TAB to reselect the app). In most applications Shift--~ will cycle through the current app's windows, which is probably closest to what you're looking for.– Mic ChannelCommented Apr 4, 2016 at 18:37
-
1I know about it, it's not what I want.– user178294Commented Apr 4, 2016 at 20:42
-
2If you want to send it all the way to the back, which window should be your focused? The previous selected window?– sayzlimCommented Nov 24, 2016 at 1:02
3 Answers
Short answer: No, Apple does not provide an API that allows you to alter an application window index except by bringing a window to the front (index 1). There are no elegant solutions. But:
Long answer: Yes, You can use AppleScript to effectively move a window to the back of a stack of AppleScript-able windows by collecting a list of windows, then rapidly moving each one (except the frontmost) to the front, leaving the chosen window at the back.
Here is an example of an AppleScript which sends the frontmost Finder Window to the back.
tell application "Finder"
set winList to every window whose visible is true
if not winList = {} then
repeat with oWin in (items 1 through -2 of reverse of winList)
set index of oWin to 1
end repeat
end if
end tell
This script is based on a solution by JMichaelTX discussed on the KeyboardMaestro forum.
The reshuffling is incredibly fast, but in the Script Editor you can inspect how it works, leaving "506" on the bottom and popping "502-505" up in a way that preserves their order:
get every window whose visible = true
--> {Finder window id 506, Finder window id 505, Finder window id 504, Finder window id 503, Finder window id 502}
set index of Finder window id 502 to 1
--> 1
set index of Finder window id 503 to 1
--> 1
set index of Finder window id 504 to 1
--> 1
set index of Finder window id 505 to 1
--> 1
You can map this AppleScript to a service or keyboard shortcut, either by a) putting the script into a Run AppleScript action inside an Automator service, or b) using a launcher (Alfred, Keyboard Maestro etc.). For details on Applescript keyboard assignment see: How do I assign a keyboard shortcut to an AppleScript I wrote?
This may satisfy OPs needs -- it is unclear from the original post. This solution can also be extended to multiple AppleScript-able applications. I am not, however, aware of a solution to make it work effectively with a mix of scriptable and non-scriptable windows, due to the fact that in AppleScript, System Events
addressable windows for non-scriptable applications do not have a set index
verb/property. There exists an "AXRaise" action for some windows when assistive devices / accessibility is turned on, but this also does not apply to all windows. Elaborate hacks exist that involve walking through each active application and show/hiding or minimizing/restoring windows, but they are a mess.
Related discussions:
-
Is it possible to send window of any app to the back, instead of the window of a specific app?– Di LiuCommented Jun 22, 2019 at 21:32
-
-
Since Mojave, my understanding is that controlling Finder with AppleScript now needs permissions to run (untested). If you are getting errors like errAEEventNotPermitted then there are solutions to add these permissions -- see related discussions: forums.developer.apple.com/thread/106949 Commented Nov 22, 2019 at 15:24
-
This is a great solution, any way to make it work across windows of multiple applications? I'd like to be typing in my terminal with my browser on top. Commented Jan 4, 2022 at 11:57
-
How do you do that not with finder but with any frontmost application ?– mjsCommented Oct 4, 2022 at 20:06
Your question isn't very clear, but if what you want is a shortcut to cycle through all windows of the currently active app, you should be able to do this with the Command~ keyboard shortcut.
The ~ key is usually located at left of the 1 key.
Just to clarify, what the Command~ keyboard shortcut does is cycle through all windows of the current app you're in. For example, if you're using MS Word and have three documents open, it will cycle through those three documents.
However, the Command~ keyboard shortcut does not cycle through Tabs. For example, if you have Safari open with three windows and each window has five tabs open, using this shortcut will cycle through the three windows, not through the individual tabs.
Another option that may achieve what you want is the CommandM keyboard shortcut. However this minimises the currently active window to the Dock, so I suspect that's not what you want.
If I've misunderstood your question totally, please clarify.
-
I think that this is the use case that the OP wants: say I have the messages app open in front of my mail app and I want to quickly bring the mail app to the foreground and send messages to the background, I can do a keyboard shortcut and the messages app will be behind my mail app. I tried your keyboard shortcut and this did not accomplish that.– owlswipeCommented Nov 28, 2016 at 22:06
-
1I think you mean the ` key. ~ is the only printed when Shift is held and ` is pressed– CrowderCommented Mar 23, 2019 at 20:49
-
1The OP question is perfectly clear for me, because I happen to use Linux Desktop, and it is very convenient to middle click application bar to send it to the back– MareckyCommented Oct 19, 2021 at 10:22
-
The question is extremely clear. He is not talking about cycling he is just talking about sending the active window behind all other windows, it is 2024 KDE plasma has this option you just press S+Left-click and the window goes back– kisaiCommented Aug 6 at 15:27
I agree with Crowder's comment. I'm pretty sure an example of the intent of the OP was to recover from e.g. the having a set of 4 windows on your screen that you've taken the trouble to arrange nicely and then accidentally clicking on some background window (thus bringing it to the front and partially/fully covering those 4 windows). You then have to individually bring all of the original 4 windows back to the front one by one instead of just sending the accidental front window to the back. Bringing any window to the front again is easy using Expose, but recovering from accidentally bringing a window to the front is a royal pain in macOS. Linux is good this way (as it also is with focus follows mouse, but that's another topic...). And I know you can minimize the offending window, but subsequently fishing specific windows out of the dock is yet another macOS pain point...
-
1As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.– Community BotCommented Mar 12, 2023 at 23:35