10.4: Hide frontmost application using Mighty Mouse

Jan 12, '06 06:05:00AM

Contributed by: Anonymous

Tiger only hintUsing Mighty Mouse (requires 10.4.2), you can set any of the actions to open a file, script, application, etc. So I set about making the squeeze action hide the frontmost application.

The AppleScript for this is fairly simple (though, like any AppleScript, I needed to start from similar code online).

tell application "System Events"
  set app_name to name of the second process whose frontmost is true
  set visible of process app_name to false
end tell
(In case you're curious, the reason why I use the second process is because that when the script is running, the first process is the script itself.)

Save the script as an 'application bundle' in ~/Library > Scripts. Open the application bundle that was created and open the Info.plist file in Property List Editor (Developer Tools required). Add an element LSUIElement with a string value of 1. This means that when we run the script, it won't pop up in the Dock.

Now open System Preferences > Keyboard & Mouse > Mouse, and set the squeeze action to Other... and navigate to the application bundle you just created.

Alternatively, you can just download the completed application from my website.

Comments (7)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20060110152311698