AppleScript Programming/Introduction
AppleScript is an object-oriented scripting language, spesifically designed to work with inter-application communication facilitating Apple Events. An object is an instance of a predefined class with shared characteristics.
The objects one may work with using the AppleScript language may be defined within three different sources: Within the AppleScript Language itself, within macOS scriptable applications, or within third party applications. All classes and commands from these sources should be documented in the Scripting dictionaries available from the menu of the Script Editor application.
Classes of AppleScript
edit{alias, application, boolean, class, constant, date, file, integer, list, number, POSIX file, real, record, reference, RGB color, script, text, string, Unicode text}
{centimeters, feet, inches, kilometers, meters, miles, yards, square feet, square kilometers, square meters, square miles, square yards, cubic centimeters, cubic feet, cubic inches, cubic meters, cubic meters, cubic yards, gallons, liters, liters, quarts, grams, kilograms, ounces, pounds, degrees Celsius, degrees Fahrenheit, degrees Kelvin}
Commands
editWorking with AppleScript one might come across AppleScript commands, scripting addition commands, user-defined commands and application commands.
The standard additions to AppleScript contains a range of commands available to all scripts. The commands are:
activate
ASCII character
ASCII number
beep
choose application
choose color
choose file
choose file name
choose folder
choose from list
choose remote application
choose URL
clipboard info
close access
copy
count
current date
delay
display alert
display dialog
display notification
do shell script
get
get eof
get volume settings
info for
launch
list disks
list folder
load script
localized string
log
mount volume
offset
open for access
open location
path to (application)
path to (folder)
path to resource
random number
read
round
run
run script
say
scripting components
set
set eof
set the clipboard to
set volume
store script
summarize
system attribute
system info
the clipboard
time to GMT
write
Comments
editTo document comments a programmer usually writes some comments along the way. Single line comments are written after #
or --
. Multi line comments are wrapped in (* *)
.
# This is a single line comment
-- This is a single line comment
(* This is a
multi line
comment *)