3

A total noob in Applescript, please bear with me…

We have a process where we use System Events to control the Print dialog in Acrobat X. This works fine; we can "click" the Print button.

Now, we have to wait until the document is printed. While the document prints, a dialog opens, with title "Print", a progress bar and a Cancel button. We can only continue when this window closes.

So far, I have not been successful with that wait; the Applescript continues and that messes up the process.

What I have currently is (note this is part of a bigger script, and variables are defined and appear to be valid.

We have Acrobat active, and the Print dialog is open:

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

I also tried to put that code in a Timeout, but no chance.

Now, I am stuck, but I am sure it is a stupid beginner's error.

Another note: I was not able to get the name of this "Print" window using UIElementInspector.

Thanks a lot in advance for any advice.

Max Wyss
  • 3,549
  • 2
  • 20
  • 26

1 Answers1

2

Is your code enclosed in some tell application block that you haven't reported here? It should work if you move the repeat loop into the tell process block:

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
Michele Percich
  • 1,872
  • 2
  • 14
  • 20
  • Thanks a lot. Yes that code block is within a tell application "Adobe Acrobat Pro" block. But I see wher it should go, and I will try it out. – Max Wyss Apr 07 '13 at 13:02
  • It took a long time, but it seems to work now. Thanks for the help. – Max Wyss Jun 20 '13 at 07:56