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