Applescript:Open preview";“导出为pdf格式”;错误:预览得到一个错误:Can’;“不要击键”&引用;

Applescript:Open preview";“导出为pdf格式”;错误:预览得到一个错误:Can’;“不要击键”&引用;,applescript,Applescript,我想打开预览文件夹中的所有PDF,并使用“导出为PDF”将其导出到另一个文件夹 到目前为止,这是我的问题 错误 预览出现错误:无法获取击键“ “ 苹果脚本 之所以出现此错误,是因为击键返回是一个系统事件命令,并且它位于“预览告诉块”中 看起来,如果您的击键返回的意图是实际单击“保存”按钮,那么这应该对您有效 tell application "Preview" activate tell application "System Events" to tell process "P

我想打开预览文件夹中的所有PDF,并使用“导出为PDF”将其导出到另一个文件夹

到目前为止,这是我的问题

错误 预览出现错误:无法获取击键“ “

苹果脚本
之所以出现此错误,是因为
击键返回
是一个系统事件命令,并且它位于“预览告诉块”中

看起来,如果您的
击键返回的意图是实际单击“保存”按钮,那么这应该对您有效

tell application "Preview"
    activate
    tell application "System Events" to tell process "Preview"
        delay 0.2
        click menu item "Export as PDF…" of menu 1 of menu bar item "File" of menu bar 1
        delay 0.2
        click button "Save" of sheet 1 of window 1
    end tell
end tell
tell application "Preview"
    activate
    tell application "System Events" to tell process "Preview"
        delay 0.2
        click menu item "Export as PDF…" of menu 1 of menu bar item "File" of menu bar 1
        delay 0.2
        click button "Save" of sheet 1 of window 1
    end tell
end tell