2
我试图制作一个脚本,用safari打开一个swf文件,然后使用内置的“另存为PDF”功能将其打印为pdf。到目前为止,我的代码如下所示:Mountain Lion上的Applescript GUI
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菜单按钮,没有得到任何进一步的莫过于此。我想知道这是不是让山狮让我使用苹果控制按钮的问题,如果是这样,是否有修复它?任何帮助将不胜感激!
您也可以尝试使用[wkpdf](http://plessl.github.com/wkpdf/)创建PDF。 – user495470