AppleScript Programming/Advanced Code List/Hide Application

Sometimes, your script will need to do something that doesn't have an AppleEvent defined to accomplish the task. In this case, you may be able to script the task anyway by going through the graphical user-interface (GUI), using a technique called GUI Scripting.

For example, to hide frontmost application, you can do the follwing:

Then, to hide all background programs:

But when you want to hide a specific application that is at background, it gets more tricky: Safari is just an example here.

I use iKey to run this script once Adium is deactivated:

Shortly explained, it hides Adium if there is only one window (like, buddy-list) open.