我正在尝试制作一个脚本,用 safari 打开一个 swf 文件,然后使用内置的“另存为 PDF”功能将其打印为 pdf。到目前为止,我的代码如下所示:
set appleworksFolder to choose folder
tell application "Finder"
set folderItems to (files of entire contents of appleworksFolder)
repeat with I from 1 to number of items in folderItems
set the_doc to item I of folderItems
set doc_name to name of the_doc as text
tell application "Finder"
set the clipboard to doc_name & ".pdf"
end tell
if name of the_doc is not ".DS_Store" then
try
tell application "Safari"
activate
open the_doc
tell application "System Events"
tell application process "Safari"
delay 1
click menu item "Print…" of menu "File" of menu bar 1
delay 5
click menu button "PDF" of window "Print" of application process "Safari" of application "System Events"
delay 1
click menu item "Save as PDF…" of menu "PDF" of menu button "PDF" of window "Print" of application process "Safari" of application "System Events"
delay 1
keystroke "v" using command down
click button "Save" of window "Save" of application process "Safari" of application "System Events"
delay 8
keystroke "w" using command down
delay 0.5
end tell
end tell
end tell
end try
end if
end repeat
end tell
这可以看到打印对话框,但它似乎没有点击 pdf 菜单按钮,所以没有比这更进一步的了。我想知道这是否是山狮不让我使用applescript来控制按钮的问题,如果是这样,是否有解决方法?任何帮助将不胜感激!