AppleScript Basics: Simple Scripts
- Recording Actions
- AppleScript Basics
- AppleScript and the Command Line
- Simple Scripts: Comments
- When you are writing your scripts, you will want to leave comments for yourself. You can preface any line with two dashes and that line will be ignored by AppleScript. You can write whatever you want on that line.
- Dictionaries
- A useful feature of AppleScript Editor is the ability to look at the “dictionary” of scriptable applications. If you look at the dictionary for Safari, Word, or Finder, you can see what things those programs can do, and what commands it takes to get them to do those things.
- Create a news screen
- We can do the same with web browser windows that we did with Finder windows. Type the following script into your AppleScript Editor and save it as an application called “Open News Overview”:
- Automatically Reload Web Pages
- If you’ve paid attention to the “Save” screen for your scripts, there is an option which by default is unchecked called “Stay Open”. If you check this, your script will not quit when it is done. It will stay open, and can continue working.
- Talking Clock
- One of the features of the standard additions is the current date and the ability to speak out loud.
- Drag and Drop
- When you drop a file onto a program, that program gets a message explaining what happened. You can let your AppleScripts accept those messages with the “open” handler. Make a script with nothing but:
- Other Things You Might Do
- Create a simple alarm clock: ask for a message, a time, and then sleep to that time and speak that message.