Some Scriptable Applications
The purpose of this section is to alert you to some useful scriptable applications that are part of Mac OS X but which you might not otherwise be aware of.
Finder
Okay, you’re probably aware of the Finder. After all, you use it every day, and it is the favorite target application for examples in this book. But I just wanted to remind you about it one more time. The Finder concerns itself with the hierarchy of folders and files on your hard drive. It’s very good at such things as renaming files, copying files, deleting files, creating folders and aliases, and describing the folder hierarchy.
If you’re an old AppleScript hand, accustomed to scripting the Finder for other purposes, you’ll want to read about System Events, later in this section.
Internet Connect
If you connect to the Internet via modem or PPPoE, Internet Connect is a good way to query and manipulate your connection. A useful incantation is:
tell application "Internet Connect" to get properties of status
The result is a record containing valuable information. For example,
if its state
is 0, you’re not
connected to the Internet; if its state
is 4, you
are.
tell application "Internet Connect" set r to properties of status if state of r is 4 then display dialog "You're connected!" end tell
System Events
In Mac OS 9 and before, the Finder was the locus of scriptability for a lot of System functionality that had nothing to do with files and folders, such as what applications were running. This was ...
Get AppleScript: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.