• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

afterOpen event listener triggers also before open... (applescript)

New Here ,
Nov 08, 2018 Nov 08, 2018

Copy link to clipboard

Copied

Cheers.

First post here (I think) although I have been working with applescripting InDesign for a long time 😃

Yesterday I did my first try with an event listener, it works, but the problem is that it triggers twice, once before the document has opened and once when it is open.
I thought "afterOpen" should do what it sounds like... Am I doing something wrong here?

tell application "Finder"

  set TheDesktop to (path to desktop as text)

end tell

tell application "Adobe InDesign CC 2014"

  set TheScript to TheDesktop & "Startuptest.app"

  make event listener with properties {event type:"afterOpen", handler:TheScript}

end tell

Regards

Johan

TOPICS
Scripting

Views

713

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 08, 2018 Nov 08, 2018

Hello Johan,

I tried using this event handler using JS as well and found that it's fired twice if the document is opened and once when a new document is created. I am afraid this is the way it behaves and has been reported before as well, see the thread below

Re: EventListener afterOpen, delay

Now you might need to code in some workarounds in your code to avoid one of the two handler calls, some suggestions relevant to the scenario of the poster are given in the thread that i gave above. In a nuts

...

Votes

Translate

Translate
Community Expert ,
Nov 08, 2018 Nov 08, 2018

Copy link to clipboard

Copied

Hello Johan,

I tried using this event handler using JS as well and found that it's fired twice if the document is opened and once when a new document is created. I am afraid this is the way it behaves and has been reported before as well, see the thread below

Re: EventListener afterOpen, delay

Now you might need to code in some workarounds in your code to avoid one of the two handler calls, some suggestions relevant to the scenario of the poster are given in the thread that i gave above. In a nutshell you just need to maintain a state that you can check across the call of handlers to identify if the work has been done or needs to be done.

Hope this helps.

-Manan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 09, 2018 Nov 09, 2018

Copy link to clipboard

Copied

LATEST

Thank you Manan,

I should be able to do a window check with applescript as well, I'll give it a go.

Will post the result here if I get it to work.

Big thanks for the hint!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines