Show only the minimized windows of an app

The KM “Windows Switcher” shows all open windows of an app. Is there a way to display only the minimized windows in a list? In this example, that would be only the window named “Ohne Titel 2.”

I don't see such an option.

Or does anyone know of another way? With a script? Thank you very much.

I don't see a built-in way either. However everything is possible with AppleScript. However AppleScript is dependent on applications being well-behaved. Many apps are not well-behaved and don't even expose their window names, or expose a flag as to whether their are hidden. Since you didn't say exactly which apps you want this feature to work with, one cannot say whether a solution is even possible.

Here the type of AppleScript I think @Airy was thinking of, with the caveats he mentioned.

set appName to "Preview"
tell application id "com.apple.systemevents" to tell application process appName
	set nameList to name of windows whose value of attribute "AXMinimized" is true
end tell

set aList to nameList
tell application (path to frontmost application as text)
	set selectedItems to choose from list (nameList) with prompt "\"" & "Minimized windows" & "\"" default items (aList) with multiple selections allowed --https://forum.keyboardmaestro.com/t/how-to-bring-applescript-choose-from-list-to-foreground/5952/2
	if aList is false then
		return
	end if
end tell
return selectedItems

Thanks, Airy

Every app I use seems to display the minimized windows correctly. I checked this with KM “Windows Switcher.” The minimized windows appear paler (as shown in the screenshot above).

What I want is to use a shortcut to display a list of the front app windows that are minimized.

Can this be done with an AppleScript? Thank you very much.

And thanks, CRLF

I tried your script. Unfortunately, it only displays an error message.

This is how I adapted it for TexEdit. Is that correct?

I think it's because no minimized windows were found.

set appName to "TextEdit"
tell application id "com.apple.systemevents" to tell application process appName
	set nameList to name of windows whose value of attribute "AXMinimized" is true
end tell
if nameList is {} then return "No unminimized windows were found"
set aList to nameList
tell application (path to frontmost application as text)
	set selectedItems to choose from list (nameList) with prompt "\"" & "Minimized windows" & "\"" default items (aList) with multiple selections allowed
	if aList is false then
		return
	end if
end tell
return selectedItems

Yes, TextEdit should work.

No, 3 out of 5 windows are minimized.

Does the script work for you?

Huh. Yes. I runs fine here. Mojave, but that shouldn't matter.

This one targets frontmost app and takes the choose dialog out of the equation.

tell application id "com.apple.systemevents" to tell (first application process whose frontmost is true)
	set nameList to name of windows whose value of attribute "AXMinimized" is true
end tell
set AppleScript's text item delimiters to {linefeed}
return nameList as text

Ah. The appName variable should be set this way:

set appName to "TextEdit"

In your screenshot you've got TextEdit as the variable name, which is why you're getting the undefined error message

Unfortunately, that doesn't work either. What should the script do? Display a list of minimized windows?

Could you show me a screenshot of that?

Sorry, I don't understand.


Should be:

set appName to "TextEdit"

Here's what the choose dialog displays in my AppleScript Debugger

Ah, nice, it works.

But the OK button doesn't work for me to display the window.

Whew! Sweating for moment.

That is just a native AppleScript picker window that returns the results to a variable.

What kind of window do what the results to show up in?

KM , I'm guessing?

Targeting the frontmost app?

First of all, thank you for your time :slight_smile:

What I would like is to be able to display a minimized window from this list with OK.

And what would also be great is to replace “TextEdit” with “front app”.

Is that possible?

1 Like

Like the previous list picker, the AppleScript "choose from list"?

A KM Prompt With List would also allow for multiple selections.

Then, what would you like to do with the results?

Yes.

I just want to select one window from a list of minimized windows and display it so that it is no longer minimized.

This script can be adapted to do that.

Just bear in mind @Airy 's caveats that not all apps can be counted on to implement the accessibility features that this script requires to function correctly.

I'll get something together after a little while with a Prompt With List for now.

It will display the frontmost app's minimized windows in the PWL and unminimize only the windows that you select.

Here's an idea of how the AppleScript can be used with Prompt With List to list and unminimize selected window.

Image

Prompt With Minimized windows of front application.kmmacros (8.4 KB)

3 Likes

This is much more than just “an idea.” It seems to work perfectly. Thank you very, very much. :folded_hands:

Let me experiment with it a little more. I'll be happy to get back to you afterwards.

This is definitely a macro that belongs in the KM library.

Minimizing windows is not particularly well done natively in macOS. However, with a macro like this, you can compensate for everything Apple has neglected.

I think many users are unaware of the advantage of being able to open minimized windows immediately without them being permanently in the way.

1 Like

I agree 100%! I also actually created a rudimentary cave-man method to unminimize windows for that reason! But the scripting way is definitely better!

1 Like

cmd + m is quick to press to temporarily hide a window. But how do you find these windows again? The answer is: with the macro from @CRLF :clap: :smiley:

2 Likes