How to make a Finder window "active" and "selected" without clicking?

I know how to make a given Finder window the “active” window, that is to say, the window in front, the “first window”, or “window 1”. What I really want to accomplish is to make the Finder window so that I can use my arrow keys to navigate around its hierarchy. It appears to me that only clicking on a given window (among two or more windows) will do this, and that is what I am trying to avoid. The trackpad is a nuisance; it takes my hand away from he keyboard. Just a simple script. A simple command. Sorry for being so dumb. I think there must be a way to do this. Once again, what I am looking for is an AppleScript command/script that will allow me to move from Finder window to Finder window so that when I land on the one I want to navigate through, it is selected in such a way that very next action on my part is simply to use my arrow keys to move through the folders.

Many thanks ahead of time to anyone who can help

By the way, my operating system is OS 10.15.3 (Catalina). This version is not an option in the System Info dropdown menus.

Model: Mac Pro
AppleScript: 2.7
Browser: Safari 605.1.15
Operating System: macOS 10.14

  1. To have ability to navigate around hierarchy of the folder, its view options should be setted to columns view
  2. To make the current selected folder be highlighted (focused) in the Finder window you can use this:

tell application "Finder"
	reveal (choose folder)
	activate
end tell

Thank you Fredrik71,

I did try your code and it seemed to make two Finder windows separate on the screen. Then one window was surrounded by a blue “frame” and with the arrow keys I was able to make that frame move from one window to the other. But that was not what I was looking for. I wanted the arrow keys to enable me to navigate through the hierarchy of folders within the chosen folder, and once I ran the code the arrow keys seemed confined to moving the “frame” around them.

I think KniazidisR has more of the idea I am looking for. I know and understand that view options must be set to columns. That is the way I normally set my windows anyway. But I tried this code:

tell application “Finder”
reveal (choose folder)
activate
end tell

And substituting the words “window 2” for “(choose folder)” I got an error message:

“Finder got an error: window 2 doesn’t understand the “reveal” message.” number -1708 from window 2

What I am trying to accomplish is a code that will take any two or more windows (folders) and cycle through them (a different window/folder on each running of the code), then making that window/folder active in the sense that I can then use my arrow keys to navigate the internal folders and files.

Let me put it another way. For example I might have three windows open on my Desktop: Window1, Window2 and Window3, each with a different target/path (and each in columnar view). But it should be simple, shouldn’t it, to identify the windows only by their position on the desktop: Window1 is in front, Window3 is in the back and Window2 is in the middle. I just want to be able (with a “hotkey”) to switch from window to window until I land on the one I want to navigate through. Then, and only then, would I begin using the arrow keys to navigate that window’s hierarchy of folders. The problem, as I see it, is to make the chosen window active (I hope I am using the right word) so that I don’t have to click on the window to make the arrow keys effective.

I hope that is clearer.

But to cloud the issue further, I would like to create a script that would take into account any number of open windows (within reason, of course) and be able to cycle through them as described, but always ending up with that active window being immediately accessible to arrow-key navigation within its folder structure.

There. I hope I haven’t made things worse with all my descriptions.

By the way, is there a syntax issue with “Window 1” as opposed to “Window1” or “Window_1”?

Many thanks to all who see this and consider.

Windows have various properties and one of these is an index number, which is defined by the AppleScript Finder Dictionary as:

For a good discussion of this, please see the following:

https://macosxautomation.com/applescript/firsttutorial/04.html

Window1 and window_1 are seen as variables and are different from window 1.

Try this way, please:


tell application "Finder"
	set windowsNumber to count Finder windows -- as say, I have here 7 windows opened
	reveal target of Finder window (windowsNumber - 1) -- go to window 6
	activate
end tell

delay 5 -- to see only

If I’m understanding you correctly, getting what you’re after doesn’t necessarily require a script of any kind. There are two ways that I know of to actively switch windows…

  1. Press the control + F4 keys together to cycle through any windows visible from your Desktop. This shortcut will leave alone any windows you have minimized into the Dock. Once you have your target window up and active, use the arrow keys to your heart’s content.

  2. Holding the Apple key down, tap the tab key once to bring up a window showing all the applications which have open windows. Tap the tab key (while still holding command key down) to cycle through the app icons shown. When the app icon you want to go to is highlighted, release the command key and any windows that app has open will be brought to the front of your Desktop. Again, with your intended window open and frontmost, you can use the arrow keys as you wish.

There are, of course, other keyboard shortcuts available for use on active windows, to do things like move focus to text fields, the menu bar, etc. You’ll find most of that stuff in System Preferences - Keyboard - Shortcuts - Keyboard

If I happen to be lecturing you on stuff you already know, let me say sorry for that. I’m new here, so if I got this all wrong and you guys want me to go stand in the corner or whatever, I understand…

I tried control+F4 and nothing happened. I then called Apple, got someone on the line who tried the same shortcut and nothing happened. Interesting, because this shortcut is, in fact, listed in Apple’s keyboard shortcuts. But after the Apple person called a “supervisor” she came back and said, "Try Command+` (or Command+tilde, the key to the left of the “1” key). This did the trick. Just what I was looking for. Why this works and the one listed in System Preferences does not is a mystery.

My thanks to SineEyed for the tip anyway; it sent me in the right direction, even though it turned out not to be an AppleScript answer. It does leave me wondering, though, if there is an AppleScript equivalent to this keyboard shortcut, so that it might be incorporated into a script.

  1. Because Command + “`” is the shortcut of Finder’s command Cycle Through Windows (see menu Windows of the Finder’s menu bar). And we look for Finder’s windows, and not System Preferences.app’s windows. Right?

  2. You really don’t need AppleScript equivalent of your “press finger” process. Because Finder itself has whole control, and does all you need for shortcut process. It makes sense to use AppleScript only if you want your script to instruct the Finder to go to any window in any order, and not in a circle, as Finder does with Command + “`” shortcut. And I have already shown this in my last script.

The following is an AppleScript equivalent, except that the desktop is excluded and the cycle order is reversed:

tell application "Finder"
	set index of the last Finder window to 1
end tell

In most cases, it seems best just to use the keyboard shortcut, which can be remapped in System Preferences if desired.