Hardware Reference
In-Depth Information
Create Your Own Service
Services help you automate common tasks, but what about uncommon tasks—things
you'd like a service to do, but for which you can't find a prebuilt solution? Even if
you're not a programmer, you can create your own service with Automator!
To create a service, open Automator and create a new workflow (see
Create a Simple
Automator Workflow
)
, but instead of selecting Workflow as the document type, select
Service. When you do so, a few new options appear at the top of your workflow; fill
them in to specify how and where your service will work:
•
Service Receives Selected:
From this pop-up menu, choose the type
of data that must be selected for the service to appear; the service then
receives the selected data as input. For example, choose Text, Dates,
Files or Folders, Images, or Web Content. (To create a service that
requires no input at all, choose No Input.)
•
In:
Use this pop-up menu to choose whether your service should be
available in Any Application, or only in a specific application.
•
Input Is:
For certain data types only, you can use this pop-up menu to
determine whether the service acts on the Entire Selection or only the
relevant portion of it—for example, Only Addresses, Only URLs, or Only
Dates.
•
Output Replaces Selected Text:
For Text and Rich Text selections only,
check this box if you want the service to replace whatever's selected after
it runs. For example, if you select a word and run a service that translates
it into another language, you may want the translated word to replace
the original.
Then build your workflow as usual, save it, and give it a name; Automator
automatically stores it in
~/Library/Services
.
Get to Know AppleScript
Whereas Automator lets you construct a workflow visually by dragging and dropping actions
into a list, AppleScript is a
scripting language
—a type of simplified programming language
that runs only in a specific environment (in this case, OS X). That means AppleScripts can
run only on a Mac, and because your Mac must interpret the commands in the script as it
runs, an AppleScript won't have the high performance of a conventional Mac app. Even so,
AppleScripts can look and act like ordinary Mac apps. You may already be using some apps
that were written in AppleScript without even realizing it!