oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button Mac Hacks

Mac Hacks: Wild Hard Drive


Also in Mac Hacks:

Kiosk Mode in Internet Explorer 5

IE 5: Printing Framesets

Mac Hacks: The Launch

Here's a fun hack that demonstrates how easy it is to script events in the Finder. With a little help from the AppleScript editor, I created a self-running applet that causes the hard drive icon to dance around the screen after startup, then return safely to its home location.

I created and ran this hack on a PowerBook running System 9.04 and using Script Editor 1.4.3. If you haven't used AppleScript before, you can find it in your Apple Extras folder.

Writing the script

One of the cool functions built into the Script Editor is the "Record" mode. In a sense, it works just like a tape recorder. You hit the Record button, then start making the moves that you want scripted. If the application is AppleScript compatible, the Script Editor will "record" your movements and write the appropriate script for them. When you're finished, simply hit the Stop button and save the script.

So, to create the script for the "Wild Hard Drive," hit the Record button, then jump over to the Finder and move the hard drive icon an inch or so. Right away you'll see something like this appear in the Script Editor window:

tell application "Finder"
	select startup disk
	set position of selection to {912, 79}

AppleScript has just recorded the new coordinates of your relocated hard drive icon. Continue to move the drive icon about the screen. Just for fun, add a loop or two; they really look nice. You'll see AppleScript recording your every move.

Once you've completed the path and returned the hard drive icon to its original position, hit the Stop button in the Script Editor. If you want to check your handiwork, hit the Run button, and the script will execute. Once you're satisfied, save your script.

Creating the self-running applet

Half the fun of creating this simple demonstration is having it launch and execute by itself. We do this by saving it as an applet.

To do so, use the Save As command in the Script Editor. In the Format drop-down menu, choose "classic applet." Then check the "Never Show Startup Screen" box and give the file a unique name.

Screen shot of Apple Script's Save As dialogue box.
To create a self-running applet, use these settings in AppleScript's "Save As" dialogue box.

Now all you have to do is double-click on the applet you've created, and it will run all by itself.

Automatic launch after system startup

To make your script launch automatically after system startup, place it in the Startup Items folder within the System folder on the Mac.

Now, after the Mac has run through its entire startup sequence, it will run the script, causing the hard drive icon to dance about the screen, then return unharmed to its original location ... much to the bewilderment of the viewer.

More AppleScript goodies ...

If you have a few helpful or entertaining AppleScript hacks, tell us about them using the Talk Back feature at the end of this article. Or if you want to send me the script (, I'll take a look at it and consider it for publication.

See you next time.

Derrick Story is the author of The Photoshop CS4 Companion for Photographers, The Digital Photography Companion, and Digital Photography Hacks, and coauthor of iPhoto: The Missing Manual, with David Pogue. You can follow him on Twitter or visit

Read more Mac Hacks columns.

Return to the Mac DevCenter.