AppleScript 编程/简介
外观
AppleScript 是一种面向对象的脚本语言,专门设计用于与应用程序间通信协作,以促进Apple 事件。对象是具有共享特征的预定义类的实例。
使用 AppleScript 语言可以使用的对象可能在三个不同的来源中定义:在 AppleScript 语言本身中,在 macOS 可脚本化应用程序中,或在第三方应用程序中。所有这些来源的类和命令都应在脚本字典中进行记录,这些字典可以在脚本编辑器应用程序的菜单中获得。
{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}
使用 AppleScript 时,您可能会遇到AppleScript 命令、脚本附加命令、用户定义的命令和应用程序命令。
AppleScript 的标准附加组件包含一系列可供所有脚本使用的命令。这些命令是
激活ASCII 字符ASCII 数字蜂鸣选择应用程序选择颜色选择文件选择文件名选择文件夹从列表中选择选择远程应用程序选择 URL剪贴板信息关闭访问复制计数当前日期延迟显示警报显示对话框显示通知执行 shell 脚本获取获取 EOF获取音量设置关于启动列出磁盘列出文件夹加载脚本本地化字符串日志挂载卷偏移量打开访问打开位置路径到 (应用程序)路径到 (文件夹)路径到资源随机数读取舍入运行运行脚本朗读脚本组件设置设置 EOF将剪贴板设置为设置音量存储脚本汇总系统属性系统信息剪贴板时间转换为 GMT写入
为了记录注释,程序员通常会在过程中编写一些注释。单行注释写在# 或 -- 之后。多行注释用 (* *) 括起来。
# This is a single line comment
-- This is a single line comment
(* This is a
multi line
comment *)