AnsweredAssumed Answered

Why two clicks to perform "odoc" AppleScript?

Question asked by SteveFransen on May 16, 2018

The use case is a button launches Preview and opens a PDF help file. The script behind the button has one step:


Send Event [ "" ; "aevt" ; "odoc" ; "Test PDF.pdf" ]


And these options…



With the FMP window in the foreground, I click the button, Preview opens and comes to the foreground, but Test PDF.pdf does not open. I click on the FMP window again to bring it back into the foreground, then click on the button again and Test PDF.pdf opens. I've tried adding an open application event script step before the open document script step so the entire script is:


Send Event [ "" ; "aevt" ; "oapp" ]

Send Event [ "" ; "aevt" ; "odoc" ; "Test PDF.pdf" ]


But that doesn't solve the problem.


Test PDF.pdf will open with one click if Preview is already open in the background, but I'd like this to work whether or not Preview happens to be open.