Cheat Sheet速查表
跳转到主要内容

AppleScript 速查表

本文根据 Devhints / AppleScript 翻译。代码示例及版本范围沿用原文。原文标注更新日期:2018-12-06。

运行

osascript -e "..."
display notification "X" with title "Y"

注释

-- This is a single line comment
# This is another single line comment
(*
This is
a multi
line comment
*)

语音输出 (Say)

-- default voice
say "Hi I am a Mac"
-- specified voice
say "Hi I am a Mac" using "Zarvox"

蜂鸣 (Beep)

-- beep once
beep
-- beep 10 times
beep 10

延迟 (Delay)

-- delay for 5 seconds
delay 5

处理程序 (Handlers)

on doubleNumber(n)
	return n * 2
end doubleNumber

set doubledValue to my doubleNumber(2)