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 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
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.
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
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
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.
This is much more than just “an idea.” It seems to work perfectly. Thank you very, very much.
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.