/ Id-Extras Forum / AfterOpen Script
-
Author
-
Wonderboy
ParticipantDoes anyone know how to use afterOpen?
I would like to have it so whenever someone opens a specific indesign file, a dialog pops up asking them questions and the user can make selections and input text.
im having trouble getting the a simple alert to pop up automatically after opening using afterOpen
Any idea?
#targetengine “main”
app.addEventListener(‘afterOpen’, function(myEvent) {
if (myEvent.target.constructor.name !== ‘new sample’) {
return;
}var myDoc = myEvent.target;
// Continue on with your code from here
alert(“testing”)
})~~Ariel~~
ParticipantThis seems to work for me, when an existing document is opened. It shows the number of pages in the document. I changed the name of the #targetengine, though, to make it persistent.
Code:#targetengine MyOpenEventapp.addEventListener(‘afterOpen’, myOpenFunction);
function myOpenFunction(myEvent){
if(myEvent.target instanceof Document){
alert(myEvent.target.pages.length);
}
}Does that help?
ArielWonderboy
Participantyes this is what i needed. thanks for the help
Wonderboy
Participanti went down a rabbit hole that is over my head.
how would i make a dialog window pop up within this function? i got an alert that tells me the document name, but im trying to get a dialog to pop up as well. would that happen within the myOpenFunction? would it call on another script?
~~Ariel~~
ParticipantDo you know how to build a dialog with ScriptUI? (There’s also a simpler way of making dialogs, but I would recommend getting to know ScriptUI.)
Once you’ve got a working dialog, just stick it in the myOpenFunction and it will pop up whenever a doc is opened.
(If you just need really simple user input, there’s also the prompt() command.)Wonderboy
Participantyeah i used it to make a dialog box. it wouldn’t work at first but after messing around with it i finally got it to work. thanks again for your help
-
AuthorPosts