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

How to run a script on InDesign startup?

New Here ,
Mar 02, 2010 Mar 02, 2010

How to run a script on InDesign startup?

Or jast after it open one document?

Is there any method like Excel VBA "Auto_Open" ?

TOPICS
Scripting
14.0K
Translate
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
Guide ,
Mar 02, 2010 Mar 02, 2010

To make a script autorun on InDesign startup, put the script in a subfolder named "Startup Scripts" (under the app or user Scripts folder).

To make a script run on InDesign document opening, attach an event listener to the beforeOpen or afterOpen document event, e.g. (in JS):

app.addEventListener( "beforeOpen" , function(){alert("Opening a document...");} );

Note that the script must have a session persistence (#targetengine 'mysession') if your event handler is enclosed within. You alternately can put the event handler in an external file, then no session scope is required.

Translate
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 ,
Mar 02, 2010 Mar 02, 2010

Thank you very much!

Translate
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
Valorous Hero ,
Mar 02, 2010 Mar 02, 2010

To make a script run on InDesign document opening, attach an event listener to the beforeOpen or afterOpen document event...

InDesign's before/afterOpen events are practically useless — they both are sent before the document layout window opens. So you can do nothing useful with the document except perhaps getting its name. The only solution, I know about, is to use APID Toolkit's docLoaded event. If you are interested, here you can find an example of using it.

Kasyan

Translate
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
LEGEND ,
Nov 03, 2011 Nov 03, 2011

Kasyan wrote last year:

InDesign's before/afterOpen events are practically useless — they both are sent before the document layout window opens. So you can do nothing useful with the document except perhaps getting its name. The only solution, I know about, is to use APID Toolkit's docLoaded event.

As of CS5, you should be able to queue an idle task in response to the open event and then the idle task can wait for whatever condition is necessary before performing its work.

Translate
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
Guest
Nov 03, 2011 Nov 03, 2011

John,

  will that work in CS3?

Translate
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
LEGEND ,
Nov 03, 2011 Nov 03, 2011

No, CS3 did not have idle events. But really you should think about upgrading.

Also, you could have your script call out the operating system and have it start a process that waits and then calls back to InDesign. This would be ugly but doable.

Translate
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
Guest
Dec 31, 2012 Dec 31, 2012

Hi,

 

I have written following code...

#targetengine "session"

main();

function main(){

    var myApplicationEventListener = app.eventListeners.add("beforeOpen",myEventInfo);

}

   

function myEventInfo(myEvent){

    var docName = app.documents.item(0).name;

    var myString = "Current Target: Import ::" + myEvent.currentTarget.name+ docName;

    alert(myString);

}

   

as event is "beforeOpen", how to take a document object actually i want to get all links from a document.

Is it possible?

Thanks,

Translate
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
LEGEND ,
Dec 31, 2012 Dec 31, 2012

as event is "beforeOpen", how to take a document object actually i want to get all links from a document.

Is it possible?

No. Use the afterOpen events.

You could, I suppose, instantiate an afterOpen event handler in your beforeOpen event handler...but why would you do that?

Translate
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
Guest
Dec 31, 2012 Dec 31, 2012

Actually what is happening is when i am trying to open a document InDesign is crashing because of one corrupted image, so while openning a document i need to track which image is corrupted or invalid and handle it in a different way.

Translate
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
LEGEND ,
Dec 31, 2012 Dec 31, 2012

I don't know of any way of determining if an item is corrupted before crashing InDesign…

Harbs

Translate
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
Guest
Dec 31, 2012 Dec 31, 2012

Is it possible using APID toolkit?

Or any other way

Translate
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
LEGEND ,
Dec 31, 2012 Dec 31, 2012

Well, you can try moving the linked images so that InDesign cannot get to them, and then opening the document.

Or perhaps opening in a more recent version of InDesign.

Translate
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
Guest
Dec 31, 2012 Dec 31, 2012

you mean to say is move all linked images to some other location, and open document. Then how to track corrupted image

No .. I just dont get it..

Thanks,

Translate
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
LEGEND ,
Dec 31, 2012 Dec 31, 2012
LATEST

Well, if it opens, then your theory was correct.

Move half the images back and try again.

Repeat until you know which ones.

Translate
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
Guest
Nov 03, 2011 Nov 03, 2011

Thank YOU!

i will have my IT guy look at this!

Translate
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