
- Where did it come from?
- Buzzwords
- What can you do with it?
- What do you need to get started?
- What kind of programs are recordable? How about scriptable?
- How can I tell if it's AppleEvent capable, AEOM based, AppleScriptable or attachable???
- How do I make scripts? (using ScriptEditor)
- How do I know what functions are AppleScriptable for an application?
- Where is AppleScript going?
AppleScript was created with System 7. AppleEvents are the basis for how it really works. Applications can communicate with eachother using AppleEvents, whereas AppleScript allows humans to command applications. However, it is complicated for programers to create Scriptable applications and this is the reason why there are relatively few that support it. Once you find an application that is scriptable, there is a wealth of added functionality that the user (you) can reap from it.
You can save time with the use of the simple scripting syntax that AppleScript provides. Examples: Fetch-continuous retry, FolderWatcher, UnderControl's scripting.
tell application "UnderControl"activate
send message to connected users "Hello world"end tell
set result to "Hello world!"
"Hello world"
display dialog "Hello world!"
Future workshops will cover the syntax of AppleScript.
System 7.1 or later with the AppleScript Runtime Kit installed. System 7.5 comes with the necessary components, except for one... Scriptable Text Editor.
"AppleEvent capable" programs are ones that support the four basic AppleEvents: Open, Print, Quit, and Run, and are mostly non-scriptable. A plain AppleScriptable application is one that just has an AppleEvent dictionary (more on AE Dictionaries later) and is AppleEvent capable. Programs that are based on the AEOM are completely recordable, scriptable and AppleEvent capable. However, some applications are not based on AEOM and are still recordable because of how they handle user commands. The final form of applications are "attachable applications." They allow the user to put scripts inside of them. QuidProQuo is a good example of this... it has some built-in scripts that tell WebCenter to perform actions like resetting the WWW log file.
This is tricky, and not straightforward at all. Programmers rarely advertise their programs as being any of the above. The ways of determining this are for the advanced user only..... If you can do "Open Dictionary" on an application, it is AppleScriptable. (In other words, if it has an "aete" resource, it is scriptable.) You can tell if it is AppleEvent capable by looking at the "SIZE" resource with a special SIZE editor. Attachable applications are most easily spottable if they come with a "Scripts" folder of some kind, and have a menu while the program is running where those scripts are attached to. There currently is only one tool for being able to tell if a program is AEOM ready, but it is so hard to use, it is not worth mentioning.
The best way to start is by watching AppleScript record your actions. Run the ScriptEditor application. Click on record, switch to the Finder and do some actions such as making aliases, opening windows, duplicating files, or throwing files away. Switch back to ScriptEditor and Stop recording. Recordability has it's limitations. Take note that recording does not recognize repetetive tasks. You can do the task once, edit the script, and make it as repetetive as you wish.
Take a look at the script you just created. Notice that it almost looks like plain english!
Demonstration: Editing scripts... the functionality of ScriptEditor. (syntax checking)
Check out the AppleEvent Dictionaries of programs. Not every program has one. The dictionaries describe the commands and syntax that the particular program recognizes.
Use the "Open Dictionary..." command in ScriptEditor to look at the files in the "System Folder:Extensions:Scripting Additions" folder by using the "Go to Scripting Additons folder" button. This folder contains a bunch of the built-in functions that are included with AppleScript, such as functions to get the date/time, display a dialog, choose a file, and do file reading/writting.
Additional functionality can be gained for AppleScript by putting OSAX's (Open Scripting Architecture Extensions) in your "Scripting Additions" folder. Probably one of the most useful OSAX is Jon's Commands because it removes many of the limitations the Finder puts on dealing with files.
AppleScript currently is a 68K extension. With the future release of AppleScript 2.0, it will finally be PowerPC native. AppleScript is a little poky as far as speed right now because it is a partially compiled, partially interpreted language.