Skip to main content
deleted 78 characters in body
Source Link
CJK
  • 5.6k
  • 9
  • 19

If you're running it as an Automator quick action, then you can close all windows except the frontmost window of the frontmost application by using the code below inside a Run AppleScript action (you can delete any sample code that appears, including on run {input, parameters}...end run:

tell application id "com.apple.SystemEvents" to tell the ¬
    first process where the path of its application file ¬
    is the path towhose frontmost application as= texttrue to tell ¬
    a reference to windows 2 thru -1 to if¬
 it exists then ¬
 if exists then tell the value of attribute "AXCloseButton" to click

If you're running it as an Automator quick action, then you can close all windows except the frontmost window of the frontmost application by using the code below inside a Run AppleScript action (you can delete any sample code that appears, including on run {input, parameters}...end run:

tell application id "com.apple.SystemEvents" to tell the ¬
    first process where the path of its application file ¬
    is the path to frontmost application as text to tell ¬
    a reference to windows 2 thru -1 to if it exists then ¬
    tell the value of attribute "AXCloseButton" to click

If you're running it as an Automator quick action, then you can close all windows except the frontmost window of the frontmost application by using the code below inside a Run AppleScript action (you can delete any sample code that appears, including on run {input, parameters}...end run:

tell application id "com.apple.SystemEvents" to tell the first process ¬
    whose frontmost = true to tell a reference to windows 2 thru -1 to ¬
    if exists then tell the value of attribute "AXCloseButton" to click
Source Link
CJK
  • 5.6k
  • 9
  • 19

If you're running it as an Automator quick action, then you can close all windows except the frontmost window of the frontmost application by using the code below inside a Run AppleScript action (you can delete any sample code that appears, including on run {input, parameters}...end run:

tell application id "com.apple.SystemEvents" to tell the ¬
    first process where the path of its application file ¬
    is the path to frontmost application as text to tell ¬
    a reference to windows 2 thru -1 to if it exists then ¬
    tell the value of attribute "AXCloseButton" to click