extendscript - Adobe Indesign script change to uppercase and copy text to clipboard -


i try create adobe indesign script select text, change selected text uppercase , copy same text. stuck.

#target "indesign"    var mydoc = app.activedocument;      if(app.documents.length != 0){      if(app.selection.length == 1){          try{                         //var text = app.selection[0].              var frame1 = page.textframes[0];              //var frame2 = page.textframes[1];                frame1.texts.everyitem().select();              //frame1.              app.copy();           }          catch(e){              alert ("please select text", "selection");          }      }   else{      alert ("please select text", "selection");    }    }  else{  	alert("something wrong");  }

var mydoc = app.activedocument;  if(app.documents.length != 0){     if(app.selection.length == 1){         try{                        //var text = app.selection[0].             //var frame1 = app.selection[0].textboxes[0].contents;             var frame1 = app.documents[0].pages[0].textframes[0];             frame1.contents = frame1.contents.touppercase();          }         catch(e){             alert ("exception : " + e, "exception");         }     }  else{     alert ("please select text", "selection");   }   } else{     alert("something wrong"); } 

here using selected object:

var mydoc = app.activedocument;  if(app.documents.length != 0){     if(app.selection.length == 1){         try{                        var frame1 = app.selection[0];             frame1.contents = frame1.contents.touppercase();          }         catch(e){             alert ("exception : " + e, "exception");         }     }  else{     alert ("please select text", "selection");   }   } else{     alert("something wrong"); } 

copying clipbaord:

var mydoc = app.activedocument;  if(app.documents.length != 0){     if(app.selection.length == 1){         try{                        var selectedstuff = app.selection[0];              //uppercase selection right away.             //if textframe selected, in textframe gets uppercased.             //if part of text selected, part of text uppercased.             selectedstuff.contents = selectedstuff.contents.touppercase();             ///////////////              //app.copy(copies selected item, not text) find out what's selected before shove onto clipboard.             if(selectedstuff instanceof textframe){                 //the selected item textframe, textframe can't pasted notepad, lets select text in frame instead.                 app.selection = selectedstuff.texts;                 }             //now copy selection. @ point, text should selected, pasting should work.             app.copy();          }         catch(e){             alert ("exception : " + e, "exception");         }     }  else{     alert ("please select text", "selection");   }   } else{     alert("something wrong"); } 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -