2

After switching to an app with Cmd + Tab, which has multiple windows open, if the frontmost window in not the desired one, additionally Cmd + ` needs to be done to reach the desired window. But at times, the latter shortcut may not effect a switch when the target app has only single window open.

Is it feasible to determine the total count of open windows for the target app? (E.g. by having the count of open windows shown under the app icon in app switcher UI or in the Dock)

  • 1
    If you have a follow on question about one specific app, Please link to it in a comment to my answer. We might be able to dig up an AppleScipt dictionary or python script to do this for one case but the general answer is likely going to be complicated. – bmike Jul 22 '18 at 19:18
3

No - there's not a general solution for this. You might need to add a follow on question explaining why you need this information and what you'll want to do once you have that information. Some apps are well behaved and you can use automation to request a count of active windows or use Mission Control or script things in python with an objective C bridge to count all windows based on your definition of “open” whether it excludes hidden / minimized / on another virtual space or screen or just the windows visible.


Keep in mind if you’re scripting things, with App Nap / Sudden Termination / Power Nap and all the advanced power scheduling technology that's been added to macOS - you can't really even define if some apps are even running. You will have an app running and show up in the dock and app switcher when each and every thread of that app is killed and nothing is running on the kernel. Similarly - you can have threads running on the kernel - doing active work when the app is technically not running and you won't see it in the dock or the app switcher.

Quite simply, the OS and applications deeply integrate to start and stop things and the illusion that an app is running is no longer something you want to manage. You should expect that when you switch to an app or launch an app, that it responds quickly and lets you get back to work regardless of the status of it running or not before you asked it to do work.

2

While as mentioned in the question, it is not natively possible to show the count of open windows for an app in either the app switcher UI or the Dock, there are a couple easy methods (that I personally employ) to determine if an app has one or more window(s) open and easily switch to the the desired one. Setup and usage for both of them is described below.

Note: These approaches are applicable only for the apps that show a window and is not applicable for the apps which run in background and Menu Bar apps.


Method I : Using Mission Control

Mission Control gives you a birds eye view of all the running apps with open window in the system. To invoke Mission Control, press the Mission Control (F3) key on the keyboard.

You'll need to check Group windows by application under System Preferences app → Mission Control to see windows grouped by application to easily serve your requirement by knowing at a glance if the target app has one or more windows open.

Mission control display both without window grouping by application and with is shown below for easy reference (Notice that the same set of apps and windows are currently open in both the cases). The former approach has the benefit that the app group also shows the app icon towards bottom centre of the group which helps in easy identification.

Without grouping:

With grouping:

Additionally, you may have more than one Spaces active at the same time and the app windows may be scattered across different Spaces. Only the windows present on the current Space are shown at a time and you can easily switch between Spaces without leaving Mission Control view.

You now have an idea if the target app has one or more windows open. While in Mission Control view, you can simply click on the window group for the target app to switch to it (instead of doing Cmd + Tab). Once the target app is frontmost, you can perform Cmd + ` to switch to desired window of the app (if it has more than one window open).

This approach has a drawback that an app may additionally have one or more minimised windows and the Mission Control view doesn't show them, thereby defeating the purpose. That's where the second approach as discussed below helps.


Method II : Using Hot Corners

You'll need to configure Hot Corners for this approach.

Hot Corners is a feature of macOS that lets you assign instant actions for when you move the mouse pointer to any one of the four corners of your Desktop.

For more information on Hot Corners, read the discussion What are Hot corners in macOS?.

Configure any one of the four corners via Hot Corners configuration to show Application Windows.

Now switch to the target app using either Cmd + Tab or Mission Control (as discussed in Method I). Once the target app is frontmost, use Hot Corners by moving the mouse pointer to the configured corner. All the open windows for the app are shown.

The benefit of this approach is that it also shows the minimised window(s) (which are shown towards the bottom in smaller size). To switch to the one desired window among many open, simply click on it with your mouse pointer. If the desired window is minimised, it will be automatically maximised and brought to front.


I employ both the above discussed approaches as one of the powerful workflows in my day to day usage of macOS. (The screenshots may be a bit unintuitive, as I have set the Menu Bar to Auto Hide, have High Contrast display enabled and transparency effects turned-off in macOS).

You must log in to answer this question.

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