首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Applescript -用作快捷批处理时不起作用

Applescript -用作快捷批处理时不起作用
EN

Stack Overflow用户
提问于 2016-03-15 17:57:11
回答 1查看 112关注 0票数 0

我正在尝试创建一个脚本,将一个文件拖放到其中,automator在Adobe Acrobat中打开它,然后applescript在Acrobat中运行一个操作,将其作为优化的PDF保存到特定文件夹中,然后在预览中打开新文件,并使用石英过滤器来减小PDF的大小。

如果我已经在Acrobat中打开了一个文件,并且只运行脚本,它就会在Acrobat中执行操作,保存文件,然后打开预览(还没有得到进一步的结果)。但是如果我把文件放到drop上,它只会给我一条错误消息。

代码如下:

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

发布于 2016-03-18 11:00:39

我会推荐一些类似这样的东西。

代码语言:javascript
复制
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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36007924

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档