General Application Scripting
When applied correctly, application scripting extends programming into the actual semantics of a given application. The scripting terminology files created by the application developer open up internal data structures and reveal commands for third-party control. Certainly, it’s more appropriate to talk about “recipients,” “subjects,” and “messages,” rather than text 1 of data item 5 of window 2, when working with mail. Fortunately, this is possible by scripting definition files. Example 9-9 demonstrates the appropriateness of addresses and names for communicating with Apple’s Mail application.
Example 9-9. Using mail terms to script the Mail application
tell application "Mail" set new_msg to make new outgoing message tell new_msg set the visible of it to true make new to recipient at the end of every to recipientwith properties
{address:"noone@nowhere.org", name:"Mr. Fred Noone"} set the subject to "This is a Test" set the content to "Please disregard this message" end tell end tell
The commands you use and the data you access will, of course, vary by application. As you discovered earlier in this chapter, each ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access