2016-03-15 28 views
0

我正在嘗試創建一個腳本以用作將液滴放到其上的液滴,automator在Adobe Acrobat中打開它,然後applescript在Acrobat中運行一個操作將其作爲優化PDF保存到特定文件夾中,然後在預覽中打開該新文件並使用石英濾鏡來減小PDF的大小。Applescript - 在用作液滴時不起作用

如果我有一個已經在Acrobat中打開的文件,並且只是運行腳本,它會在Acrobat中執行該操作,保存該文件,然後打開預覽(沒有進一步)。但是,如果我把文件放到水滴上,它只會給我一個錯誤信息。

下面的代碼:

on run {input, parameters} 
    tell application "System Events" 
     tell application process "Acrobat" 
      tell application "Adobe Acrobat Pro" to activate 
      -- runs the custom action in Acrobat 
      click the menu item "SAVE in 0-SEND" of menu 1 of menu item "Action Wizard" of the menu "File" of menu bar 1 
     end tell 
    end tell 

    tell application "System Events" 
     keystroke return 
     -- clears the action finished message 
    end tell 

    tell application "Adobe Acrobat Pro" 
     activate 
     close documents saving no 
     quit 
    end tell 

    -- this doesn't work yet 
    tell application "Finder" 
     tell application "Preview" 
      open input 
     end tell 
    end tell 
end run 
+1

液滴必須實現'上open'處理程序。直接參數傳遞表示已刪除項目的別名說明符列表。 – vadian

+0

正確處理Droplet的模板:http://www.macosxautomation.com/applescript/sbrt/sbrt-10.html – jweaks

回答

0

我會建議沿着這些路線的東西...

on run 
    set aFile to choose file with prompt "Please select the file to process" 
    processPDF(aFile) 

    -- cleanup, quit the application 
    tell application "Adobe Acrobat Pro" to quit 
end run 


on open (theFiles) 
    repeat with aFile in theFiles 
     processPDF(aFile) 
    end repeat 

    -- cleanup, quit the application 
    tell application "Adobe Acrobat Pro" to quit 
end open 


on processPDF(theFile) 

    -- open your file 
    -- do something with theFile here. 
    -- close the file 

end processPDF 
相關問題