Skip to main content
Participating Frequently
June 23, 2014
Answered

How to make at startup script that fits spread on open

  • June 23, 2014
  • 2 replies
  • 776 views

Hi there,

Does anyone know how to make a startup script for InD CS6 that fit spread too screen when document open?

I've tried this and it works but I've get a dialog that says "Object is not valid":

#targetengine "session"

main();

function main(){

var myEventListener = app.eventListeners.add("afterOpen", excuteScript);

}

function excuteScript(){

var myD = app.documents[0];

app.layoutWindows[0].zoom(ZoomOptions.FIT_SPREAD);

}

This topic has been closed for replies.
Correct answer Jump_Over

Hi,

I mean:

//...

function excuteScript (ev) {

     var myD = app.documents[0];

     if (ev.target.constructor.name !="Document")

          myD.layoutWindows[0].zoom(ZoomOptions.FIT_SPREAD);

     }

Jarek

2 replies

Known Participant
June 24, 2014

How do you do that in applescript?

DaljonasAuthor
Participating Frequently
June 25, 2014

Why use Applescript? Java runs on any plattform.

Jump_Over
Brainiac
June 23, 2014

Hi,

eventListener "afterOpen" is triggered twice - after doc opening and after applying a window to it.

In 1st case you are seeing an error since no window is applied yet.

You could check an event.target.constructor.name and run your function body if it is !="Document"

(just with 2nd case only)

Jarek

DaljonasAuthor
Participating Frequently
June 23, 2014

Hi Jump_Over and thank's for reply.

I'm a total newbie when it comes to scripting.

Can you show me how you mean?

Jonas

Jump_Over
Jump_OverCorrect answer
Brainiac
June 24, 2014

Hi,

I mean:

//...

function excuteScript (ev) {

     var myD = app.documents[0];

     if (ev.target.constructor.name !="Document")

          myD.layoutWindows[0].zoom(ZoomOptions.FIT_SPREAD);

     }

Jarek