1、打开脚本编辑器,点击启动台 -> 其他 -> 脚本编辑器,或直接浏览器中输入applescript://,然后按回车键。
2、新建文稿,按Command+s组合键进行保存,选择保存位置和文件格式,格式选择[脚本]。
3、点击录制按钮,如图

4、新建一个Finder窗口,把跟Finder相关的所有操作都做一遍。如打开文稿,打开图片,打开文件夹,拖拽窗口大小,设置文件显示方式(图标、列表、分栏等)。
5、会发现脚本文稿中多了一些代码,这就是录制得到的代码。点按停止按钮,停止录制。
6、目前发现只能对Finder进行录制操作,其他软件应该是不可以。
7、这个功能可以帮助更好的理解脚本编辑器能做的事,以及脚本编辑器的一些语法。
8、示例录制得到的代码如下:
tell application "Finder"
activate
close Finder window id 963
make new Finder window
set target of Finder window 1 to folder "Desktop" of folder "userName" of folder "Users" of startup disk
set target of Finder window 1 to folder "Documents" of folder "userName" of folder "Users" of startup disk
set target of Finder window 1 to folder "Downloads" of folder "userName" of folder "Users" of startup disk
set target of Finder window 1 to folder "Documents" of folder "userName" of folder "Users" of startup disk
set target of Finder window 1 to folder "xxx" of folder "xxx" of folder "Documents" of folder "userName" of folder "Users" of startup disk
set current view of Finder window 1 to icon view
set current view of Finder window 1 to list view
set current view of Finder window 1 to column view
set current view of Finder window 1 to flow view
set current view of Finder window 1 to column view
open document file "xxx.txt" of folder "xxx" of folder "xxx" of folder "Documents" of folder "userName" of folder "Users" of startup disk
close Finder window id 1118
end tell
本文介绍了如何使用Mac的脚本编辑器AppleScript的录制功能。通过打开脚本编辑器,新建文稿并保存为脚本格式,然后启动录制,执行Finder的相关操作如打开文件和设置显示方式,最后停止录制并查看生成的代码。目前该功能仅限于Finder,有助于初学者理解AppleScript的语法和功能。

1万+

被折叠的 条评论
为什么被折叠?



