Adobe InDesign脚本更改为大写并将文本复制到剪贴板 [英] Adobe InDesign script change to uppercase and copy text to clipboard
本文介绍了Adobe InDesign脚本更改为大写并将文本复制到剪贴板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试创建一个Adobe InDesign脚本,该脚本将选择文本,将所选文本更改为大写,然后复制相同的文本。
我被卡住了。
I am try to create an Adobe InDesign script that will select text, change the selected text to Uppercase and then copy the same text. I am 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 it is using the 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");
}
复制到clipbaord:
Copying to clipbaord:
var myDoc = app.activeDocument;
if(app.documents.length != 0){
if(app.selection.length == 1){
try{
var selectedStuff = app.selection[0];
//upperCase the selection right away.
//If a textFrame is selected, everything in the TextFrame gets upperCased.
//If only part of the text is selected, then only part of the text is upperCased.
selectedStuff.contents = selectedStuff.contents.toUpperCase();
///////////////
//app.copy(copies the selected Item, not only Text) so find out what's is selected before you shove it onto the clipboard.
if(selectedStuff instanceof TextFrame){
//The selected item was a textFrame, a TextFrame can't be pasted into Notepad, so lets select all the text in that frame instead.
app.selection = selectedStuff.texts;
}
//Now copy the selection. At this point, only TEXT should be selected, so pasting should always work.
app.copy();
}
catch(e){
alert ("Exception : " + e, "Exception");
}
}
else{
alert ("Please select text", "Selection");
}
}
else{
alert("Something wrong");
}
这篇关于Adobe InDesign脚本更改为大写并将文本复制到剪贴板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文