2

My workflow often involves comparing two Finder windows side by side. I use shortcut 2 (see screenshot) to quickly cycle between the windows. However, the annoying thing is that the cycle also includes the desktop as a 'window'. Instead, I would just like to cycle between the two floating windows.

The closest I've come to achieve this is shortcut 1. This shortcut excludes the desktop, but unfortunately it will also cycle between the windows of all apps. It also doesn't work properly in Split View.

Is it possible to make shortcut 2 exclude the desktop? If not, is there another method to achieve what I want?

To be clear: I really want to exclude the desktop from the cycle because that enables me to use one shortcut to switch between the windows. I'm aware that you can go to the previous window using shift, but it's just way, way easier to go back and forth using the same shortcut.

Update 1: I just discovered that my question has been asked before: Command Tilde in Finder, prevent focus on Desktop at end of cycle. However, I don't think the answer there solves the problem.

Update 2: My solution.

Screenshot of System Preferences

5
  • Both of those commands reverse direction if you add shift. If you're just swapping between 2 apps/windows, that might work.
    – Tetsujin
    Mar 6, 2020 at 7:31
  • Yes, but that means you constantly have to pay attention to which window is active and then press the shift shortcut in order to not overshoot to the wrong window. It is considerably more cumbersome than simply having only two windows in the cycle and pressing the same shortcut every time.
    – Daan
    Mar 6, 2020 at 11:03
  • Why do you need to alternate between two windows so much? Are you differencing the file list by scrolling both windows? And have you considered using tabs instead?
    – Nic
    Mar 9, 2020 at 5:57
  • I like to have two Finder windows side by side in any situation where I need to compare files and folders or need to interact a lot with two particular folders. I much prefer having both windows visible at the same time in such cases.
    – Daan
    Mar 10, 2020 at 1:44
  • Thinking outside of the box, take a look at this answer for a similar question (comparing two Finder windows). It might save you a ton of effort: apple.stackexchange.com/a/382351/119271
    – Allan
    Mar 24, 2020 at 1:22

3 Answers 3

1

First, you're going to need an AppleScript that can swap the position of the two frontmost windows.

tell application "Finder"
    set index of window 1 to 2
end tell

Now you need a way to make this script easily accessible from the Finder. We'll use macOS services, and Automator makes this super easy for us.

  1. Open Automator
  2. Make a New Document of type "Quick Action" (or "Service" in older macOS)
  3. Drag a new Run Applescript action into the workflow. You can find it in the Utilities category, or just search for it in the search bar.
  4. Copy the AppleScript shown above into the script box.
  5. Press to try it out. You'll get an error if you have fewer than two windows open -- I'll leave that as an exercise to the reader to fix.
  6. Save the workflow as Swap Front Windows. The moment you save it, it will become accessible from the Services menu under the application menu.

At this point you can really try it out. Go to the Finder and open two windows. Then go to the menu bar, choose Finder -> Services -> Swap Front Windows. It takes a moment, but it works. That's cool, now let's hook it up as a keyboard shortcut.

  1. Open System Preferences
  2. Go into Keyboard Preferences
  3. Go to the Shortcuts tab
  4. Go into the Services category
  5. Scroll down to the bottom. Underneath General you should see Swap Front Windows.
  6. Select the "Swap Front Windows" row, then click Add Shortcut.
  7. Enter the shortcut you want to use. I recommend Ctrl + Shift + `.
3
  • Thank you. It works if you change line 2 to: set index of window 2 to 1. However, this introduces a ~400 ms delay when you switch between windows. That makes it, sadly, not an option for me. I'd still prefer to use shortcut 1 instead.
    – Daan
    Mar 15, 2020 at 12:36
  • @Daan To make it faster you'd need an always-on application that listens for global hotkeys and invokes AESendMessage directly. That's beyond what I can offer here.
    – Nic
    Mar 15, 2020 at 16:41
  • Thank you, I'll look into that. Best case scenario, I was hoping for some hidden Mac setting you could change to exclude the desktop, but that probably doesn't exist.
    – Daan
    Mar 15, 2020 at 21:14
0

It's not entirely obvious from the Shortcuts Preference pane listing, but on most MacOS applications, you can switch the focus between two windows in their index order by with keystroke Command-` for the next window and keystroke Command-Shift-` for the previous window.

1
  • 1
    Thanks for your answer. I'm aware that you can use the shift-key to go back, but I really want to exclude the desktop from the cycle so that I can use the same shortcut to go back and forth. I've edited my question to make this clear.
    – Daan
    Mar 14, 2020 at 23:21
0

In the end, the best solution turned out to be to create an AppleScript:

tell application "Finder"
    if (count windows) > 0 then
        set index of window (count windows) to 1
    end if
end tell

And bind it to a shortcut via the great utility FastScripts, which doesn't have the 0.5 second delay that you have with Automator services.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .