Windows PC style Minimize All Windows and Show Desktop on Mac OS X

UPDATE April 9, 2012
I have compiled the Apple Script below (March 23, 2012 update) into an app, so you can download it and put it in your Applications folder and use it whenever you need it. There is also a Quick Launch app, which will add a little icon menulet in the top right menu bar, so you can quickly click on it to Show Desktop whenever you want:
DOWNLOAD HERE

In order for the Quick Launch app to work, you need to place both apps in your Applications folder. You can also add the Quick Launch app to “System Preferences > Users and Groups > Login Items” if you want it to start automatically when you turn on your computer.

UPDATE March 23, 2012
Ok, so now I have found and even better solution, which is back to an AppleScript, but works even better than the ShowDesktop app below!

Go here an scroll down to the answer by Daniel Beck:
http://www.superuser.com/questions/36504/minimize-all-in-mac-os/403099

Open automator and choose new application and then drag Run AppleScript from the left side to the right side and add the following AppleScript then save it as an application… that’s it!

tell application "Finder" to activate
 tell application "System Events"
  tell application process "Finder"
   tell menu bar 1
    click menu item "Hide Others" of menu of menu bar item "Finder"
    click menu item "Minimize All" of menu of menu bar item "Window"
   end tell
  end tell
 end tell


==============================
Everything below is no longer necessary.

==============================

UPDATE March 20, 2012
Ok, I finally found somebody who has figured out how to do this correctly with instantaneous showing of desktop just like on Windows … they are genius!! Check out Everyday Software for their Show Desktop product and send them a $5 donation because it’s worth it!

http://www.everydaysoftware.net/showdesktop/index.html
UPDATED: January 3, 2011
New and improved script that will start closing windows in all applications simultaneously.

Having used Windows XP for 10+ years, I always had a little Show Desktop icon down in the bottom left in the quick launch bar (keyboard shortcut is WindowsKey+D and WindowsKey+M also works). Clicking it would instantly minimize all my open windows, and reveal my desktop underneath.

Mac OS X Lion does not have an exact duplicate of this feature. It does have F11 and the 4-finger up-swipe, but these sort move the windows to the side and you can see them around the edges. The Command+Option+ClickOnEmptySpotOnDesktop I think works ok, except it requires you to hold down Command key and the Option key and then you need to find an exposed piece of the desktop to click on.

So here is my best effort… it’s an AppleScript that will finds all the open windows and minimizes them. This would be perfect except that it takes a few seconds for it actually do it as you watch each window disappear one by one. If anybody has a solution to make this faster, let me know!

So first we will open up Automator (it’s in your Launchpad) and choose new Application. Then under Actions, you will drag the Run AppleScript action over to the right side of the screen. You will then copy an paste the AppleScript below, and save your application. You can put it anywhere you want, and then drag it to your Apple Dock so it’s available to click whenever you want.

Here is the new and improved AppleScript:

--Thanks to DJ Bazzie Wazzie on MacScripter.net forum
-- http://www.macscripter.net/viewtopic.php?pid=147285

set blackList to {} –The processes in this list will be skipped. Example: “com.apple.Finder”, “Finder”

–NOTE: This section will start minimizing windows of each application at the same time.
tell application “System Events” to set processList to (bundle identifier of every process whose visible is true) as list
repeat with processName in processList
–display dialog processName –DEBUG only
if contents of processName is not in blackList then
tell application id processName
ignoring application responses
set miniaturized of (every window whose ((miniaturizable is true) and (miniaturized is false) and (visible is true))) to true
end ignoring
end tell
end if
end repeat

–NOTE: This section is required in case there are applications (like Finder, Automator, Calculator) that will not minimize using the Application ID method above
tell application “System Events”
repeat with appProc in (every application process whose visible is true) — Get all the available applications that are visible
–display dialog (get name of appProc) –DEBUG only
if (get name of appProc) is not in blackList then
click (first button of every window of appProc whose role description is “minimize button”) — From the available applications above, click on the minimize button of every window that has a minimize button
end if
end repeat
end tell

Here is the OLD script .. do NOT use this one:

−−This is the OLD script .. don't use this one!!
tell application"System Events"
−−Get all the available applications that are visible
repeat with appProc in (every application process whose visible is true)
−−From the available applications above, click on the minimize
−− button of every window that has a minimize button
click (first button of every window of appProc whose role description is "minimize button")
end repeat
end tell

Let me know what you think!

4 thoughts on “Windows PC style Minimize All Windows and Show Desktop on Mac OS X

  1. Hi Sakia … thats a great question and I honestly have no idea how to do that, or even if its possible. If I figure it out, I will let you know and if you figure it out, let me know too!
    Thanks

  2. Thanks! I’m a Windows user so this app you’ve created works great… just one question! Is there anyway to assign a keyboard shortcut key that utilizes this app?? I’ve already tried going into system preferences, keyboard, and assigning a shortcut key but it does not work. The Quick Launch app is great but I would really love to have a shortcut key that does the same thing.

  3. I’ve just switched to a mac and this solved my biggest problem, thank you for your great script.
    If anyone runs into the error “System Events got an error: Access for assistive devices is disabled” you simply need to check ‘enable access for assistive devices’ under universal access in system preferences.

Leave a Reply