Minimize all windows on Mac OS

AppleScript to quickly minimize every window on my macOS. This is not hiding the windows, but minimizing them on the dock.

I have the issue that I tend to keep plenty of windows open on my Mac. This issue persists until my next reboot, but in some cases, I just get overwhelmed by all the mess. Unfortunately, there is no built-in feature for macOS to minimize all windows at once. But there is a simple way to do it with AppleScript.

The script

You can use this AppleScript to minimize all windows. You might get asked for accessibility permissions the first time you run it.

tell application "System Events"
  set theProcesses to (every process whose visible is true and name is not "Finder")
  repeat with proc in theProcesses
    tell proc
      set theWindows to every window
      repeat with win in theWindows
        set value of attribute "AXMinimized" of win to true
      end repeat
    end tell
  end repeat
end tell
tell application "Finder" to set collapsed of windows to true

As I am an Alfred user, I created a small workflow to execute this via Spotlight. You can download it here. Also check out my Alfred VS Code extension.

Other solutions

I stumbled upon this superuser thread asking for the same thing. The answers point out the exposé and the Command+Option+H+M key combo. The later one unfortunately doesn’t work for me, as it only hides the windows without them appearing in the dock as minimized windows.

Homepage All Blogposts

AI disclaimer: I spend hours writing my blog posts by hand, adding my own thoughts and experiences to them. In my view, purely AI-generated content lacks that human depth and isn't worth publishing. I only use AI for research and editing assistance.