"Maniuplate Window" action doesn't seem to have an option to close inactive windows of the same active app.
Here's a topic that might get you started.
Hey Alex,
Not directly, but @cdthomer has clued you in to the way of doing this natively with Keyboard Maestro.
Alternatively you could use an AppleScript in an Execute an AppleScript action:
--------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2022/02/21 00:15
# dMod: 2022/02/21 00:15
# Appl: System Events
# Task: Close Windows Other Than the Frontmost One.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @System_Events, @Close, @Windows, @Other-Than, @Frontmost
--------------------------------------------------------
tell application "System Events"
tell (first application process whose frontmost is true)
set winList to windows
set winListCount to length of winList
if length of winList > 1 then
set winList to rest of winList
repeat with theWindow in winList
tell theWindow
try
tell (first button whose subrole is "AXCloseButton")
perform action "AXPress"
end tell
end try
end tell
end repeat
else
display notification (winListCount as text) & " Window Was Open!" with title "Close Windows Failed" subtitle "ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท" sound name "Tink"
end if
end tell
end tell
--------------------------------------------------------
This should work with most normal apps, although you may end up with unsaved windows asking you what to do in some of them.
That would be true too with Keyboard Maestro native actions of course.
And I have a script in the thread Chris T. recommended that works specifically with the Finder.
-Chris
1 Like