Applescript For Mac



I have an AppleScript that reads a text file that contains a list of addresses, it then creates a message for each of those address in Outlook with a subject and sends the email automatically. This has been for working for the past year or so but it's no longer working as expected. AppleScript Tutorial for Excel. Legacy Notice: The AppleScript products are designed to guide Mac users that use Excel for Mac 2004 and 2008. Later versions should use the VBA Macros which are cross-platform compatible with Excel for Mac 2011 and up including Office 365.

AppleScript is an English-like, easy-to-understand scripting language built into every Mac. AppleScript can automate hundreds of AppleScript-able applications, performing tasks both large and small, complex and simple.Learn AppleScript: The Comprehensive Guide to Scripting. AppleScript FAQ: How do I create comments in AppleScript? Answer: There are two ways to create comments in AppleScript, and I show examples of both comment approaches in this article. AppleScript comments with '-' or '#' syntax. First, you can use the '-' syntax. This lets you create a comment like this at the beginning of a line. The easiest way to get started with AppleScript is to use some scripts that others have written already. Scripts are small files that contain a list of commands that tells your Mac what functions to perform and when. Fortunately, Apple is kind enough to provide you with several completed scripts with your installation of Yosemite.

Home > Articles > Apple > Operating Systems

  1. What Is AppleScript?
Page 1 of 4Next >
If you're an avid Mac user, you've probably heard of two technologies that seem sort of alike: Automator and AppleScript. Ben Waldie points out the differences and similarities in the two technologies, explaining when to use each one to save yourself some keystrokes (and headaches).
From the author of
Automator for Mac OS X 10.5 Leopard: Visual QuickStart Guide
Automator for Mac OS X 10.5 Leopard: Visual QuickStart Guide

For many Mac users, AppleScript and Automator are terms that bring about a sense of confusion. This is unfortunate, considering that both technologies are generally targeted at typical users (non-programmers, in other words) and designed to make life easier through automation.

Much of the confusion centers on the similarities between these two applications:

  • Both automate time-consuming or repetitive tasks.
  • Both interact with Mac applications.
  • Both are targeted toward everyday Mac users.

But AppleScript and Automator are actually quite different. This article will attempt to clear up some of the confusion surrounding these technologies.

What Is AppleScript?

AppleScript is a scripting language that has been built into the Mac operating system since the early days of System 7. Like the rest of the operating system, AppleScript has steadily improved and expanded over the years.

With AppleScript, you write a script—essentially a set of instructions—to perform tasks within the existing applications on your Mac (the application must support AppleScript), or within the operating system itself. Scripts are typically written in an AppleScript editor such as Script Editor, which you can find in the following folder on your Mac:

After writing your script, you can run it from within Script Editor, or save it and run it as an application.

Aside from some basic user-interaction capabilities, AppleScripts don't normally have interfaces. Once launched, they simply appear in your Mac's dock, and they run virtually invisibly.

Applescript

Unlike programming languages such as Objective-C and Java, AppleScript's syntax is much like the English language, which means that users can learn it quite easily with no prior scripting or programming experience. Mac users often create simple scripts by trial-and-error, or by copying and pasting together pieces of existing scripts found online.

Apple provides some sample scripts with AppleScript; look in the following folder on your Mac:

Even without any prior knowledge of AppleScript, if you open some of these scripts in Script Editor you'll probably be able to figure out what many of them do (see Figure 1).

Figure 1 The New Applications Window sample script.

Related Resources

  • Book $55.99
Mac
  • eBook (Watermarked) $55.99
  • Web Edition $55.99
2 0 likes 11,959 views Last modified Apr 10, 2014 8:53 AM

Getting started


Getting started with applescript

Software

Although there are 3rd party editors available, you don't need any external software to write, compile or run AppleScript scripts. OS X comes bundled with the AppleScript Editor, which you can find on your startup disk at /Applications/Utilities/AppleScript Editor.app.


Learning Guides

Two widely recommended books for those just starting out with Applescript are


Apple Training Series: AppleScript 1-2-3

Sal Soghoian (Author), Bill Cheeseman (Author)


Learn AppleScript: The Comprehensive Guide to Scripting and Automation on Mac OS X

Hamish Sanderson (Author), Hanaan Rosenthal (Author)


These are available from large online book retailers and distributors in electronic and print format at quite reasonable prices (at time of writing they're around $20-$25 each). Each is a substantial volume that will serve both as tutorial and reference work.


There are many other books available, but I can personally recommend both the above as highly valuable. 'AppleScript 1-2-3' is probably the better of the two if you are new to AppleScript and to computer programming in general. It is one of the few computer books I've come across that genuinely lives up to the promise of 'no previous experience required'. 'Learn AppleScript' covers some more advanced topics and treats some of the same topics in more depth. The two books are best seen as complementaries rather than alternatives.


Apple provides some free resources, the most useful of which is:


The AppleScript Language Guide


There is an inconspicuous 'PDF' icon at the top right of that page which will allow you to download the entire guide in PDF form, which may be more convenient than reading the online HTML version.


Applescript For Each

The AppleScript Overview


may also be of interest, though it is largely aimed at developers wishing to make their apps scriptable with AppleScript, rather than for those using AppleScript for scripting. However, if you would like or need a better conceptual understanding of AppleScript and how it fits in with the entire OS X ecology, this will be of interest.


Getting Started with AppleScript

You may often find references in Apple documentation to something called 'Getting Started with AppleScript' but without a link.

Applescript Tutorial Pdf

This, and pretty much all other public domain documentation for AppleScript, has been collated on an third-party (i.e, not hosted, supported or endorsed by Apple, Inc.) site here:




Getting help

Sample


OS X Technologies is the ASC forum for most AppleScript questions,


but they also do appear on the Developer's forum too.


Perhaps the largest active community of expert and novice AppleScripters alike can be found on the Apple AppleScript mailing list:



A useful external resource both for problem solving and general reference is

http://macscripter.net.


The following site also lists a number of useful links and AppleScript resources:

Using 'do shell script'

One of AS's biggest strengths is its ability to incorporate shell scripts through the 'do shell script' command. However, this is often a source of frequent questions from new scripters. See this article for reference on the ins-and-outs of using shell scripts with AS:





Distributing your work


How do I protect my source code?


If you distribute your app without creating a 'run only' version, others will be able to see and modify your source code. To create a 'run only' version use File > Export... and change the File Format: to 'Application'. Check the 'run only' option at the bottom of the dialogue. Note that in earlier versions of the AppleScript Editor and as stated in some of the learning guides above, the 'run only' option was found in File > Save As...' . That is no longer the case.



How do I set the version number for my public releases?

Getting Started With Applescript


See https://discussions.apple.com/thread/3132455



Applescript Sample Code

How do I create an 'Application Support' folder for my app?


See https://discussions.apple.com/thread/4885832?answerId=21505599022#21505599022