2 Replies Latest reply on Jan 9, 2013 2:25 AM by Cr8tve

    Help!!! new...

    Cr8tve

      Hi Forum,

       

      I m new to indesign; looking to have script for "finding color"...

      necessity is: to find particualr color used on "a word", "a sentence", "a paragraphs" or on a "full page" and alert "Amazon color is in USE"... after a clicked on alert, the script should end ...

       

      otherwise

       

      if the document don't have "particualr fill color".. then next loop in the script will continue.....

       

      here a bit i have.

       

       

      try {

      var mydoc = app.activeDocument;

      var textcolors =mydoc.stories.everyItem().paragraphs.everyItem().characters.everyItem().getElements();

      for (i=0; i<textcolors.length; i++)

          textcolor = textcolors[i];

           if (textcolor.fillColor.name == "Amazon"){

                   alert("Amazon color is in USE:");

                   button.onClick=exit();

      }

      }

           catch (e) {}

       

      next loop follows.......

       

       

      any help on this...

        • 1. Re: Help!!! new...
          Trevorׅ Adobe Community Professional

          Hi Cr8tive

           

          Welcome to the forum

          Your question title is not very cr8tive to say the least!

          Please try name them something more indicative like "Alert and quit script on finding text with specific color" or "Find colored text"

           

          Either you should use greps (or Text finds) this should be several tens of thousand of times quicker on long documents than the way you are going about it

           

          Try this and don't forget to say thanks and mark the answer as correct.

           

          Trevor

           


          app.changeGrepPreferences = app.findGrepPreferences = null;
          var doc = app.activeDocument, colorfind;
                 app.findGrepPreferences.fillColor = doc.swatches.itemByName("Black"); // change to Amazon if The swatch exits in the doc
                 colorfind = doc.findGrep() 
                 if (colorfind.length !=0) {alert ("Amazon color is in USE: on page " + colorfind[0].parentTextFrames[0].parentPage.name); exit();}
          alert("The Script Didn't Exit");    
          

          • 2. Re: Help!!! new...
            Cr8tve Level 1

            Thanks ~trevor~.

             

            Sorry, my title should have been more indicative and understandable to help me...

             

            thanks for your reply....

             

            very usefull. to find...

             

            I thought assigning fillColor term will find and alert all the fill strokes and objects and text...

             

            Anyways.. useful too...

             

            thanks trevor