How do I hide applications with Applescript?

Hey, gang.

Don’t you hate when people are unexpetedly peering over your shoulder to see what you are doing on your computer! Well, me too!

So… what I am looking to do is script the following commands…
Switch to finder… easy enough
Hide all apps - you know the Option, shift, H command - havne’t found an applescript command for this…
and minimize finder window. - easy enough.

So - does anyone know how to write out the Hide Other Apps command in Applescript?

This works on my machine.

tell application "Finder" to activate

tell application "System Events" to ¬
	set visible of (every application process whose visible is true and name is not "Finder") to false

– Rob

Thanks, Rob…

I’m going to need to brush up on my System Events.

can’t you just tell the Finder to do this?

tell application "Finder" to set visible of (every application process whose visible is true and name is not "Finder") to false

it works for me …

Yep, Finder can handle it but I’ve been lead to believe that Finder will simply pass the command off to System Events anyway. The way I see it, Finder has enough to do already so I’ll use System Events to carry some of the burden whenever possible. With that said, if the script needs to be backward compatible (pre-OS X), one should use the Finder. :wink:

– Rob