Alvin Alexander | Java, Scala, Unix, Perl, Mac OS X

AppleScript dialog text FAQ: "How can I display an AppleScript dialog showing multiple lines of text?"

This is actually surprisingly easy, and there are a couple of ways to do it. Here are a few examples:

display dialog "Line 1
Line 2
Line 3"

Running this program displays the following AppleScript text dialog:

An AppleScript dialog that displays several lines of text.

Here's another way to accomplish the same thing:

AppleScript dialog FAQ: How can I display an AppleScript dialog with a textfield (text field)?

A frequent AppleScript question is "How do I prompt a user to enter some text?" Here's how you display an AppleScript dialog to prompt a user to enter a simple piece of information, in this case their name:

display dialog "What is your name?" default answer ""

Running this AppleScript dialog code results in the following dialog:

Want to get started writing your own AppleScript programs? If so, just open the Applications folder, then the AppleScript folder, and then double-click the ScriptEditor. This is the application you use to edit your AppleScript programs.

As a quick little test, once you have the ScriptEditor open, type this text into the editor:

display dialog "Hello, world"

Then press the Run button. You should see the text "Hello, world" displayed in a dialog, with Cancel and OK buttons, as shown in the following figure:

I haven't used it yet, but AE Monitor looks like it might be a good tool to see the Apple Events that are firing on your Mac OS X system. As I get more into Mac-specific programming (using Cocoa, Xcode, and AppleScript) I just wanted to make a note to remember this.


The Mac OS X Activity Monitor is a cool utility. As shown in the following figure, the main screen shows all the processes running on your system, the user that owns the process, the percent of CPU it's using, the virtual memory it's using, and more. My most common thing here is to sort by memory or CPU use to get a general idea of what's going on.

I generally use Spotlight when searching my Mac for a file, but there are times it doesn't work, especially when I'm trying to find a file that contains a phrase I know. For instance, I may have a file named "Fred.txt", and it contains the phrase "foo bar", but when I open Spotlight and type in "foo bar", the file Fred.txt never shows up.

One of the cool things I just discovered on my Mac is the slideshow capability of the Finder. This can be a great tool for previewing a collection of images, or just to rotate images on your screen just for fun. Just highlight a few images, right-click, and choose the Slideshow option.

The DigitalColor Meter application is a cool little utility that comes free with Mac OS X. It has one simple purpose: to let you determine the color of a pixel of an image. Actually, it's a bit more than that, but that's what I use it for.

I haven't had the problem of a frozen application on my Mac OS X laptop in a long time, but when it does I can never remember the keystroke combination to bring up the Force Quit dialog. The key combination is [Option][Command][Esc], which I know at this moment because I'm looking at it in a book.

Since I can't remember that combination I'm hoping this mnemonic will help: "Oh Crap Eddie", where "Oh" stands for "Option", "Crap" == "Command", and "Eddie" == "Esc".

If you've ever wanted to see your Dashboard widgets outside of the normal Dashboard environment, Amnesty Widgets lets you run your widgets directly on your desktop. It's not free, but if it's something you always wanted, you can download a free trial.


I just found the RubySearch dashboard widget for Mac OS X, and I like it. It offers a simple interface to your local ri/rdoc repository, with hyperlinking between classes, methods, superclasses, etc. It may be a lot better than going back and forth between a Terminal window and typing ri.


In a previous tip I discussed how to create a Mac sticky note from inside a Cocoa application, but I forgot to mention about how to use stickies as a standalone application.

Fortunately, it's pretty easy. Just open your Applications folder, and click the Stickies application icon. Once the Stickies application is started, just click File, and New Note to create a new sticky note, or press [Command][N].

I've been having a blast these last few days with Mac OS X Dashboard Widgets. Apple has assembled a nice collection of them, and they're all easy to install. Just download them (they seem to all be zip files), double-click the zip file to extract the contents, and then double-click the installer. Best of all, the widgets are free, fun to play with, and in some cases, they may even help your productivity.

I just learned about Mac Stickies, and they're pretty cool. If you're in a Cocoa application (like Safari, TextMate, and others) you can select text and/or graphics, and then easily save the content to a sticky note on your Mac desktop. To save the content you can either (a) remember the [Command][Shift][Y] keystroke, or else (b) click the application menu item (i.e., the "Safari" menu item if you're using Safari), then Services, then Make New Sticky Note.

The picture below shows what a Mac sticky note looks like when it's created on the desktop.

At least once a week (and more likely once a day) I need to look up the spelling or meaning of a word. Interactive spell-checking is built into many Mac OS X applications (like TextMate), so that saves me when I'm typing. But a cool thing that's also built into many Mac OS X applications is the ability to easily get a dictionary definition for a word in a document.

Mac Finder FAQ: How can I delete a file using just the keyboard, i.e., some keystroke combination?

Lots of people ask me if the only way to delete a file is to drag it to the trash can on the Dock. After all, pressing the [delete] key sure doesn't delete it.

The short answer is yes, you can delete a file in the Mac Finder with the keyboard by:

If you're a mouse user, and you need to move up the folder hierarchy when using the Finder, an easy way to do this is to Command-click the folder name at the top of the current Finder window. I've shown this in the following image. To display this menu I didn't just click the folder icon, I held down the [Command] key while clicking it. This lets me easily move up one or more levels in the folder hierarchy just by selecting one of the other folder names in the drop-down list.

Every once in a while I get a similar message from a new Mac OS X user: Help, I've hidden a window from an application, how do I get it back? Having freaked out the first time I accidentally hid a window, I know what that feeling is like.

Fortunately bringing back a hidden window is easy, if not obvious. Just go to the Dock, and click the application icon for the window you accidentally hid. For instance, let's say you accidentally hid a Safari window. Just go to the Dock, and click the Safari icon. Instantly your hidden window comes back into view.

Mac OS X has a couple of cool tricks for helping you focus on just one application at a time. One of them is the "hide all other programs" trick.

To hide windows from all other applications, and just show windows from your current application, type [Option][Command][H]. Instantly all the other windows are hidden.