国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 辦公 > Photoshop > 正文

PS中執行N遍選定動作的腳本

2024-08-21 23:16:24
字體:
來源:轉載
供稿:網友

一個單步的動作,用了這個腳本,就可以重復執行100遍1000遍。
上面就是一個路徑描邊100遍的效果,吼吼~ 不知道大家明白用處沒有?(以前老是困惑不停地去點動作,點個幾十次來重復一個任務)

不容易啊。這次這個腳本前面的函數都是抄襲的,一些是抄ps自帶的腳本,還有一個建立快照是這里的:http://www.ps-scripts.com/bb/vie ... ;highlight=snapshot 感謝老外。再次謝謝xyblueidea 斑竹和其他朋友的支持鼓勵!

下載:執行n遍動作

|||

貼出代碼,方便指正優化

操作對象
任何錄制好的動作;

操作結果
對選定的動作,重復執行指定次數;(效果要靠動作本身實現)

用法
把解壓出來的 “執行n遍動作.jsx” 文件復制到 “ps安裝目錄/預置/腳本” 下,重新打開ps以后就可以在~
[菜單- 文件-腳本] 里面找到 “執行n遍動作”
或者解壓出來,在開著ps的情況下,直接雙擊也可以用。

備注
執行操作前可以先建立快照,如果對操作結果不滿意,可以通過快照返回。
(不過如果是多個文件、保存關閉之類的操作就別選了,恐怕會出錯 )

 

#target photoshop
app.bringtofront();
// 重復執行n遍選中的動作
/////////////////////////////////////////////////////////////////////
// function: globalvariables
// usage: global action items that are reused
// input: <none>
// return: <none>
/////////////////////////////////////////////////////////////////////
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: <none>
// 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: <none>
// 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:'重復執行選定動作',/
        group: group{orientation: 'column',alignchildren:'left',/
                corrdination: panel { orientation: 'row', /
                        text: '選擇動作', /
                                cla: group { orientation: 'row', /
                                        d: dropdownlist {  alignment:'left' },/
                                        }/
                                act: group { orientation: 'row', /
                                        d: dropdownlist {  alignment:'left' },/
                                        }/
                                },  /
                num: group { orientation: 'row', /
                                    s: statictext { text:'執行次數:' }, /
                                    e: edittext { preferredsize: [50, 20] } ,/
                                    }, /
                snapshot:group{ orientation: 'row', /
                                    c: checkbox { preferredsize: [16, 16]} ,/
                                    s: statictext {text:'建立快照(根據動作內容適當選擇)'},/
                                    }, /
                },/
        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 ('-_-!!! 至少得運行一次吧?')
        win.group.num.e.text='1';
        g=1
    }else {
        var b=win.group.snapshot.c.value;        
        if(b && app.documents.length) {createsnapshot(g+"遍動作執行前");} //安全起見,建立快照
        for(i=0;i<g;i++){
        doaction(ddaction.selection,ddset.selection) //執行選擇的動作
        }
        this.parent.parent.close();
    }
}
win.center();
win.show();

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 济南市| 上虞市| 报价| 舒城县| 嵊州市| 谷城县| 象山县| 麦盖提县| 二连浩特市| 上虞市| 景德镇市| 东乌珠穆沁旗| 高尔夫| 泰来县| 金华市| 吐鲁番市| 桂平市| 文登市| 溧水县| 山丹县| 安丘市| 左云县| 特克斯县| 施秉县| 漳平市| 工布江达县| 金川县| 皮山县| 微博| 建水县| 布拖县| 衡阳市| 察隅县| 白城市| 斗六市| 伊春市| 昌乐县| 滕州市| 井冈山市| 沭阳县| 永新县|