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
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
...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
Copy link to clipboard
Copied
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!