Skip to main content
Participant
January 20, 2014
Question

Is it possible to srcipt something that reads text and make an appropriate image visible?

  • January 20, 2014
  • 1 reply
  • 373 views

I have never written a script for indesign before so I am not really familiar with how it works

Eessentailly, I have a text box that a user would be writting a state in. I then want the script to take that as input, and then make a hidden image of that state visible.

Also, is it possible to have th script always running, or would the end user have to run it?

Thank you!

This topic has been closed for replies.

1 reply

Jump_Over
Legend
January 21, 2014

Hi,

It is possible using eventListeners. Look at example below and be awared that this is an example ONLY:

To switch this ON run:

#targetengine "session"

var myDoc = app.activeDocument;

myDoc.addEventListener("afterSelectionChanged", myDisplay);

function myDisplay(myEvent){

     if(app.documents.length == 0) return;

     var curDoc = app.activeDocument;

     if(curDoc.selection.length == 0) return;

     var

          myInput = curDoc.textFrames.item("input"),

          myOutput = curDoc.pageItems.item("output");

     if (!myInput.isValid || !myOutput.isValid) return;

     if (myInput.contents == "ON") myOutput.visible = true;

     else myOutput.visible = false;

}

to switch this OFF run (or quit InDesign):

app.activeDocument.eventListeners.everyItem().remove()

Assumings:

  • input textFrame is named "input" (I mean in "Layer's Panel")
  • output pageItem is named "output"
  • type "ON" to make "output" visible

Jarek