Copy link to clipboard
Copied
I'm sorry to asking this again.
But I never figured out how to deal with afterOpen event listener.
I know this event dispatches twice (on document openning and on window openning).
But even if I wrote my function to work on LayoutWindow target, it's running BEFORE the window is shown. I noticed that if I use InDesign's UI to open the file, the script runs wrong (BEFORE the layout window is shown). If I drag and drop a document to InDesign, the script runs fine. It also works fine if the document I'm openning is not the first one in InDesign.
Could anyone help me on this?
I need ro run my function AFTER the document window is shown.
var e = app.addEventListener("afterOpen" , main);
function main(ev) {
if (ev.target instanceof LayoutWindow) {
alert("Document window is shown");
}
}
Copy link to clipboard
Copied
Hello,
Give the code below a try for you needs.
#targetengine "session"
main();
function main() {
app.addEventListener("afterOpen", myEventFunction, false);
}
function myEventFunction(myEvent) {
if (myEvent.parent.constructor.name == 'LayoutWindow' ) {
alert( "Hello");
}
}
Regards,
Mike
Copy link to clipboard
Copied
Same from my previous code.
If is the first document openning, the alert shows BEFORE the window shows.
If is the second+ document to be opened, the alert shows right.
If the document is dragged into InDesign, the alert shows right too.
Just goes wrong in the first openning. Which is exactly the case I need.
Copy link to clipboard
Copied
It works fine for me as a startup script with Indesign 2020 on Mac OS Mojave 10.14.6. What are you running?
I made a short .mov showing it work but I dont konw how to get it uploaded.
Regards,
Mike
Copy link to clipboard
Copied
I'm on Windows 10 and InDesign CC2020.
And, as always while developping, running the script from ESTK.
Maybe because of this?
I'll try to put it on the startup script.
Thank you so much!
// EDITED //
Not working even putting the script on the startup folder.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more