PS中執(zhí)行N遍選定動(dòng)作的腳本(2)_PhotoShop基礎(chǔ)教程
貼出代碼,方便指正優(yōu)化
操作對象:
任何錄制好的動(dòng)作;
操作結(jié)果:
對選定的動(dòng)作,重復(fù)執(zhí)行指定次數(shù);(效果要靠動(dòng)作本身實(shí)現(xiàn))
用法:
把解壓出來的 “執(zhí)行N遍動(dòng)作.jsx” 文件復(fù)制到 “ps安裝目錄\預(yù)置\腳本” 下,重新打開ps以后就可以在~
[菜單- 文件-腳本] 里面找到 “執(zhí)行N遍動(dòng)作”
或者解壓出來,在開著ps的情況下,直接雙擊也可以用。
備注:
執(zhí)行操作前可以先建立快照,假如對操作結(jié)果不滿足,可以通過快照返回。
(不過假如是多個(gè)文件、保存關(guān)閉之類的操作就別選了,恐怕會(huì)出錯(cuò) )
#target photoshop
app.bringToFront();
// 重復(fù)執(zhí)行N遍選中的動(dòng)作
/////////////////////////////////////////////////////////////////////
// Function: GlobalVariables
// Usage: global action items that are reused
// Input:
// Return:
/////////////////////////////////////////////////////////////////////
function GlobalVariables() {
gClassActionSet = charIDToTypeID( 'ASet' );
gClassAction = charIDToTypeID( 'Actn' );
gKeyName = charIDToTypeID( 'Nm ' );
gKeyNumberOfChildren = charIDToTypeID( 'NmbC' );
}
/////////////////////////////////////////////////////////////////////
// Function: GetActionSetInfo
// Usage: walk all the items in the action palette and record the action set
// names and all the action children
// Input:
// Return: the array of all the ActionData
// Note: This will throw an error during a normal execution. There is a bug
// in Photoshop that makes it impossible to get an acurate count of the number
// of action sets.
/////////////////////////////////////////////////////////////////////
function GetActionSetInfo() {
var actionSetInfo = new Array();
var setCounter = 1;
while ( true ) {
var ref = new ActionReference();
ref.putIndex( gClassActionSet, setCounter );
var desc = undefined;
try { desc = executeActionGet( ref ); }
catch( e ) { break; }
var actionData = new ActionData();
if ( desc.hasKey( gKeyName ) ) {
actionData.name = desc.getString( gKeyName );
}
var numberChildren = 0;
if ( desc.hasKey( gKeyNumberOfChildren ) ) {
numberChildren = desc.getInteger( gKeyNumberOfChildren );
}
if ( numberChildren ) {
actionData.children = GetActionInfo( setCounter, numberChildren );
actionSetInfo.push( actionData );
}
setCounter ;
}
return actionSetInfo;
}
/////////////////////////////////////////////////////////////////////
// Function: GetActionInfo
// Usage: used when walking through all the actions in the action set
// Input: action set index, number of actions in this action set
// Return: true or false, true if file or folder is to be displayed
/////////////////////////////////////////////////////////////////////
function GetActionInfo( setIndex, numChildren ) {
var actionInfo = new Array();
for ( var i = 1; i <= numChildren; i ) {
var ref = new ActionReference();
ref.putIndex( gClassAction, i );
ref.putIndex( gClassActionSet, setIndex );
var desc = undefined;
desc = executeActionGet( ref );
var actionData = new ActionData();
if ( desc.hasKey( gKeyName ) ) {
actionData.name = desc.getString( gKeyName );
}
var numberChildren = 0;
if ( desc.hasKey( gKeyNumberOfChildren ) ) {
numberChildren = desc.getInteger( gKeyNumberOfChildren );
}
actionInfo.push( actionData );
}
return actionInfo;
}
/////////////////////////////////////////////////////////////////////
// Function: ActionData
// Usage: this could be an action set or an action
// Input:
// Return: a new Object of ActionData
/////////////////////////////////////////////////////////////////////
function ActionData() {
this.name = "";
this.children = undefined;
this.toString = function () {
var strTemp = this.name;
if ( undefined != this.children ) {
for ( var i = 0; i < this.children.length; i ) {
strTemp = " " this.children[i].toString();
}
}
return strTemp;
}
}
//////////
function CreateSnapshot(name) {
function cTID(s) { return app.charIDToTypeID(s); };
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( cTID('SnpS') );
desc.putReference( cTID('null'), ref );
var ref1 = new ActionReference();
ref1.putProperty( cTID('HstS'), cTID('CrnH') );
desc.putReference( cTID('From'), ref1 );
desc.putString( cTID('Nm '), name);
desc.putEnumerated( cTID('Usng'), cTID('HstS'), cTID('FllD') );
executeAction( cTID('Mk '), desc, DialogModes.NO );
}
//////////
res ="dialog { \
text:'重復(fù)執(zhí)行選定動(dòng)作',\
group: Group{orientation: 'column',alignChildren:'left',\
corrdination: Panel { orientation: 'row', \
text: '選擇動(dòng)作', \
cla: Group { orientation: 'row', \
d: DropDownList { alignment:'left' },\
}\
act: Group { orientation: 'row', \
d: DropDownList { alignment:'left' },\
}\
}, \
num: Group { orientation: 'row', \
s: StaticText { text:'執(zhí)行次數(shù):' }, \
e: EditText { preferredSize: [50, 20] } ,\
}, \
Snapshot:Group{ orientation: 'row', \
c: Checkbox { preferredSize: [16, 16]} ,\
s: StaticText {text:'建立快照(根據(jù)動(dòng)作內(nèi)容適當(dāng)選擇)'},\
}, \
},\
buttons: Group { orientation: 'row', alignment: 'right',\
Btnok: Button { text:'確定', properties:{name:'ok'} }, \
Btncancel: Button { text:'取消', properties:{name:'cancel'} } \
} \
}";
win = new Window (res);
GlobalVariables();
var actionInfo = GetActionSetInfo();
var ddSet=win.group.corrdination.cla.d;
var ddAction=win.group.corrdination.act.d;
if ( actionInfo.length > 0 ) {
for ( var i = 0; i < actionInfo.length; i ) {
ddSet.add( "item", actionInfo[i].name );
}
ddSet.items[0].selected = true;
ddSet.onChange = function() {
ddAction.removeAll();
for ( var i = 0; i < actionInfo[ this.selection.index ].children.length; i ) {
ddAction.add( "item", actionInfo[ this.selection.index ].children[ i ].name );
}
if ( ddAction.items.length > 0 ) {
ddAction.items[0].selected = true;
}
ddSet.helpTip = ddSet.items[ ddSet.selection.index ].toString();
}
ddSet.onChange();
} else {
ddSet.enabled = false;
ddAction.enabled = false;
}
ddAction.onChange = function() {
ddAction.helpTip = ddAction.items[ ddAction.selection.index ].toString();
}
win.buttons.Btncancel.onClick = function () {
this.parent.parent.close();
}
win.buttons.Btnok.onClick = function () {
g=Number(win.group.num.e.text);
if(g<1){
alert ('-_-!!! 至少得運(yùn)行一次吧?')
win.group.num.e.text='1';
g=1
}else {
var b=win.group.Snapshot.c.value;
if(b && app.documents.length) {CreateSnapshot(g "遍動(dòng)作執(zhí)行前");} //安全起見,建立快照
for(i=0;i doAction(ddAction.selection,ddSet.selection) //執(zhí)行選擇的動(dòng)作
}
this.parent.parent.close();
}
}
win.center();
win.show();
Photoshop在線視頻教程 Photoshop視頻教程下載
- 多媒體學(xué)Photoshop CS4視頻教程 Photoshop CS3專家講座視頻教程 Photoshop照片處理視頻教程 最新Photoshop CS4教程 Photoshop婚紗與寫真實(shí)用教程 Photoshop CS4教程_基礎(chǔ)篇 Photoshop CS4教程_實(shí)例篇 Photoshop畫漫畫視頻教程 最新Photoshop CS4視頻教程 photoshop繪畫技巧視頻教程 Photoshop CS全面通教程(下) photoshop cs4視頻教程 PhotoshopCS2中文版視頻教程 PS CS4視頻教程 PS后期效果圖處理視頻教程 photoshop繪畫與合成視頻教程 Photoshop CS4 通道、特效視頻教程 Photoshop文字藝術(shù)效果100例視頻教程 Photoshop CS全面通教程(上) PS卡通畫教程 ps照片處理視頻教程 photoshopCS4中文版完全自學(xué)手冊 Photoshop照片處理實(shí)例視頻教程 Photoshop從頭學(xué)系列視頻教程 Photoshop CS4 視頻教程 Photoshop平面設(shè)計(jì)視頻教程 Photoshop實(shí)例教程海報(bào)制作
- PS人物數(shù)碼照片處理技法大全視頻教程 Photoshop CS 質(zhì)感傳奇素材CD 《大師之路》Photoshop CS2教程 祁連山打造逼真名貴男士手表 平面三維設(shè)計(jì)七種武器II Photoshop CS4完全自學(xué)教程 萬晨曦現(xiàn)場講授photoshop入門視頻教程 Photoshop制作機(jī)械蜘蛛 21互聯(lián)photoshop cs視頻教程 Photoshop CS3專家講堂視頻教程 Photoshop CS2 高手之路 Photoshop實(shí)例視頻教程 photoshop實(shí)例教程100例 Photoshop應(yīng)用技巧 FIF 小組Photoshop視頻教程 Photoshop CS3特輯視頻教程下載
- PS新手教程:PS鋼筆工具的使用
- PS新手教程:PS畫筆面板工具的預(yù)設(shè)方法
- PS新手教程:六種常用的去除文字的方法
- Photoshop新手教程:Photoshop必看的快捷方式
- PS新手教程:通道混和器的應(yīng)用技巧詳解
- photoshop中快捷方式操作的學(xué)習(xí)
- PS新手教程:用PS摳出玻璃杯融入環(huán)境
- PS新手教程:用PS橡皮擦摳簡單背景頭發(fā)
- Photoshop新手教程:制作中國古典特色效果
- Photoshop顏色原理及調(diào)色思路教程
- Photoshop中圖案工具和圖案畫筆的基本定義
- photoshop基礎(chǔ)教程:面部潤色及添加睫毛
- 相關(guān)鏈接:
- 教程說明:
PhotoShop基礎(chǔ)教程-PS中執(zhí)行N遍選定動(dòng)作的腳本(2)。