O'Reilly logo

AppleScript: The Missing Manual by Adam Goldstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Ever-Useful every Keyword

As you've seen on Sidebar 4.3, the every keyword is an extremely powerful tool for obtaining a list of items. You can use the Finder to get every file of the folder "Applications", or use TextEdit to get the name of every document. No matter how you use it, the every keyword is a huge timesaver.

Moreover, when you use the every keyword, you're guaranteed to get a list as the result. That makes every a perfect companion to use with the choose from list command; the combination of these two commands lets you obtain a list and then present the list onscreen.

An Example: Displaying a List of Running Programs

Seeing a list of all your running programs is enormously helpful, because it lets you check what invisible programs are working in the background—and, in some cases, hogging your computer's processing power. You could, of course, use the Activity Monitor program (stored in your Applications Utilities folder) for this task. But you could also do it with AppleScript, and that's a lot more fun and educational.

To write such a script, you have to command Mac OS X's hidden System Events program, which monitors all the other programs running on with your Mac. Proceed like this:

  1. In Script Editor, open System Events's dictionary (File Open Dictionary, or Shift--O).

    Page Sidebar 3.4 explains the magic behind AppleScript dictionaries.

  2. Click the Processes Suite flippy ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required