빠른 참조

AppleScript 빠른 참조 치트시트

macOS용 AppleScript 빠른 참조 가이드: osascript CLI 실행, 시스템 알림, 음성 합성(say), 지연 시간, 비프음, 커스텀 핸들러.

· 게시일

터미널 osascript 명령어 실행부터 macOS 앱 UI 자동화까지 AppleScript 작성 및 실행을 위한 빠른 참조 가이드입니다.

AppleScript 실행

터미널에서 실행 (osascript)

# 인라인 표현식 실행
osascript -e 'display notification "Task completed!" with title "Build Script"'

# 스크립트 파일 실행 (.scpt 또는 .applescript)
osascript script.scpt

네이티브 시스템 알림

display notification "Backup finished successfully" with title "System Status" subtitle "Automated Backup"

주석

-- 한 줄 주석

# 이것도 한 줄 주석

(*
여러 줄
주석 블록
*)

사운드 및 오디오

음성 합성 (say)

-- 기본 시스템 음성
say "Build succeeded"

-- 지정된 시스템 음성
say "Warning: low battery" using "Zarvox"
say "All systems nominal" using "Samantha"

시스템 비프음 (Beep)

-- 비프음 1회
beep

-- 비프음 여러 회
beep 3

실행 지연 (Delay)

-- 5초 동안 실행 일시 정지
delay 5

핸들러 (함수 / Handlers)

on doubleNumber(n)
    return n * 2
end doubleNumber

set doubledValue to my doubleNumber(21)
-- → 42

다중 인자 핸들러

on showDialog(msg, titleText)
    display alert titleText message msg as informational
end showDialog

my showDialog("Operation completed.", "Success")

애플리케이션과 상호작용

tell application "Finder"
    activate
    open folder "Documents" of home
end tell

tell application "Google Chrome"
    reload active tab of front window
end tell

관련 주제