Minimize all windows on Mac OS
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.