AppleScript is a powerful English scripting program that allows the user to create applications, from useful math solvers to games. This guide will show you the basics of AppleScript and how simple it is to use it compared to, for example, batch.
Steps
Step 1. Locate the Script Editor
The Script Editor should be under AppleScript in the Applications folder.
Step 2. Learn to look up commands easily in the dictionary
Go to 'File'> 'Open Dictionary'. Select AppleScript. A window with the AppleScript dictionary will open and you can search for all the necessary commands.
Step 3. Learn the meaning of the icons in the header
'Stop' stops recording. 'Run' runs the script. 'Event Log History' displays the usage history of the script. 'Result History' displays what happened during the execution of the script. 'Print' prints the script. 'Bundle Contents' collects the commands in the script.
Step 4. Learn to save files in different formats
To do this, go to 'File'> 'Save As'. Click on 'File Format' and choose the type of format you need.
Step 5. Learn simple commands, such as the 'beep' command, the 'talk' command and the 'dialog' command
-
For the 'beep' command, type: beep
-
For the multiple 'beep' command, type: beep 2 (any number can be used)
-
For the 'talk' command, type: say "enter some text"
-
For the 'dialog' command, type: display dialog "enter text"
Step 6. Learn to use the Script Assistant
It is very useful when you are creating a long and complex program. To activate the Script Assistant, go to 'Script Editor'> 'Preferences'. Click edit. Select 'Use Script Assistant'. Close and reopen Script Editor. Now, when you type a command, the ellipsis will appear next to it, completing the word. Press F5 to view all possible terms. Press 'Enter' on the term you want. This makes scripting much easier and faster.
Step 7. Search the Internet
There are many websites on AppleScript.
Step 8. Read books to learn more
There are many great books on scripting.
Advice
- Make sure, if you publish a program, that you test it thoroughly and fix any bugs.
- Try creating something useful, like a password maker or math problem solver.
- Try to make the code more fluid and compact. Try reducing three lines of code into one command if you can.
- Examine other programs created with AppleScript so you can understand how the various commands were used. To do this, search for "Example Scripts" or look in the AppleScript folder for "Example Scripts".
- Save often.
Warnings
- Don't create destructive programs.
- Reduce the 'beep' commands to the bare minimum, the user may get annoyed.