我想打开包含预览的文件夹中的所有pdf,并使用"导出到PDF"将其导出到另一个文件夹。
到目前为止,这是我的问题。
预览出错:无法获得击键" "
tell application "Finder"
set fl to files of folder POSIX file "/Users/documents/PDFs" as alias list
end tell
repeat with f in fl
tell application "Preview"
open f
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
end tell
keystroke return
end tell
end repeat
答案 0 :(得分:0)
您收到该错误是因为keystroke return
是一个系统事件命令,您可以在"预告告诉块"
看起来keystroke return
的意图是实际点击"保存"按钮,那么这对你有用......
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