【问题标题】:Applescript: Wait until "Print" dialog closes in Acrobat XApplescript:等到 Acrobat X 中的“打印”对话框关闭
【发布时间】:2013-03-25 13:11:27
【问题描述】:

Applescript 的菜鸟,请多多包涵……

我们有一个过程,我们使用系统事件来控制 Acrobat X 中的“打印”对话框。这工作正常;我们可以“点击”打印按钮。

现在,我们必须等到文档打印完毕。打印文档时,会打开一个对话框,标题为“打印”、进度条和取消按钮。只有当这个窗口关闭时我们才能继续。

到目前为止,我的等待还没有成功; Applescript 继续运行,这会打乱整个过程。

我目前拥有的是(注意这是更大脚本的一部分,变量已定义并且看起来是有效的。

我们已启用 Acrobat,并且“打印”对话框已打开:

tell application "System Events"
   tell process "Acrobat"
      -- now we set all the options in the Print dialog, 
      -- which is in the window Print
      click button "OK" of window "Print
   end tell
end tell

delay 5
-- this gives Acrobat time to get printing and to open that print dialog window

repeat while exists window "Print"
   delay 1
end repeat

close active doc saving no

我也尝试将该代码放入超时,但没有机会。

现在,我被卡住了,但我确信这是一个愚蠢的初学者错误。

另一个注意事项:我无法使用 UIElementInspector 获取此“打印”窗口的名称。

非常感谢您的任何建议。

【问题讨论】:

    标签: printing dialog applescript acrobat


    【解决方案1】:

    您的代码是否包含在您未在此处报告的某个 tell application 块中? 如果您将重复循环移动到 tell process 块中,它应该可以工作:

    tell application "System Events"
        tell process "Acrobat"
            -- now we set all the options in the Print dialog, 
            -- which is in the window Print
            click button "OK" of window "Print"
            delay 5
            -- this gives Acrobat time to get printing and to open that print dialog window
            repeat while exists window "Print"
                delay 1
            end repeat  
        end tell
    end tell
    
    close active doc saving no
    

    【讨论】:

    • 非常感谢。是的,该代码块位于告诉应用程序“Adobe Acrobat Pro”块中。但我知道它应该去哪里,我会尝试一下。
    • 花了很长时间,但现在似乎可以了。感谢您的帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-12-07
    • 1970-01-01
    • 2016-09-09
    • 2010-09-05
    • 1970-01-01
    • 2011-09-21
    • 2016-11-30
    相关资源
    最近更新 更多