applescript实用脚本
时间: 2023-11-15 08:53:48 浏览: 53
当涉及到AppleScript实用脚本时,有很多不同的用例。以下是几个实用的AppleScript脚本示例:
1. 操作文件:
```applescript
tell application "Finder"
set myFile to choose file
set myFileExtension to name extension of myFile
display dialog "The selected file extension is " & myFileExtension
end tell
```
2. 操作应用程序:
```applescript
tell application "Safari"
activate
make new document
set URL of document 1 to "https://www.example.com"
end tell
```
3. 发送邮件:
```applescript
tell application "Mail"
set newMessage to make new outgoing message with properties {subject:"Hello", content:"This is a test email."}
tell newMessage
make new to recipient at end of to recipients with properties {address:"recipient@example.com"}
end tell
send newMessage
end tell
```
4. 控制系统音量:
```applescript
set volume output volume 50 -- 设置音量为50%
```