请选择 进入手机版 | 继续访问电脑版
收藏本站腾讯微博新浪微博
点点网模板设计大赛 phpchina

经典论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

蓝色理想 最新研发动态 用悬赏 三天解决问题 解决访问速度慢 论坛支持农历生日 - 给官方提建议

论坛活动及任务 归纳网站最新活动 地图任务 邮件更新任务:保护帐号安全

积分换实物,来参加蓝色理想积分兑换吧! 联系招聘客服 蓝色理想帮你找工作! 万元奖励等你拿——点点网模板设计大赛

查看: 10309|回复: 18

[作品] 能重复执行N遍选定动作的脚本~~~ (2.22更新,修正了两个Bug) [复制链接]

xiexienila 楼主
帖子
1204
体力
1923
威望
41
发表于 2008-2-21 18:58:33 |显示全部楼层


一个单步的动作,用了这个脚本,就可以重复执行100遍1000遍。
上面就是一个路径描边100遍的效果,吼吼~ 不知道大家明白用处没有?

(以前老是困惑不停地去点动作,点个几十次来重复一个任务)




不容易啊。这次这个脚本前面的函数都是抄袭的,
一些是抄ps自带的脚本,
还有一个建立快照是这里的 http://www.ps-scripts.com/bb/vie ... ;highlight=snapshot 。感谢老外  


再次谢谢XYBLUEIDEA 斑竹和其他朋友的支持鼓励!

--------------- 应作者要求帮忙更新,修正如下:
1、当前没有打开文档的时候,不建立快照,避免因此出错。
2、原本执行次数为 N+1 次,这次作了修正。

                                                ------- mzbx8888字 2.22

[ 本帖最后由 mzbx8888 于 2008-2-22 09:08 编辑 ]
附件: 你需要登录才可以下载或查看附件。没有帐号?注册
已有 1 人评分威望 收起 理由
wonton + 3 很实用~

总评分: 威望 + 3   查看全部评分

西部数码顶级域名注册商39元抢注!
xiexienila 楼主
帖子
1204
体力
1923
威望
41
发表于 2008-2-21 19:12:27 |显示全部楼层

贴出代码,方便指正优化~

操作对象:
任何录制好的动作;

操作结果:
对选定的动作,重复执行指定次数;(效果要靠动作本身实现)

用法:
把解压出来的 “执行N遍动作.jsx” 文件复制到 “ps安装目录\预置\脚本” 下,重新打开ps以后就可以在~
[菜单- 文件-脚本] 里面找到 “执行N遍动作”
或者解压出来,在开着ps的情况下,直接双击也可以用。

备注:
执行操作前可以先建立快照,如果对操作结果不满意,可以通过快照返回。
(不过如果是多个文件、保存关闭之类的操作就别选了,恐怕会出错

  1. #target photoshop
  2. app.bringToFront();

  3. // 重复执行N遍选中的动作

  4. ///////////////////////////////////////////////////////////////////////////////
  5. // Function: GlobalVariables
  6. // Usage: global action items that are reused
  7. // Input: <none>
  8. // Return: <none>
  9. ///////////////////////////////////////////////////////////////////////////////
  10. function GlobalVariables() {
  11.         gClassActionSet = charIDToTypeID( 'ASet' );
  12.         gClassAction = charIDToTypeID( 'Actn' );
  13.         gKeyName = charIDToTypeID( 'Nm  ' );
  14.         gKeyNumberOfChildren = charIDToTypeID( 'NmbC' );
  15. }
  16. ///////////////////////////////////////////////////////////////////////////////
  17. // Function: GetActionSetInfo
  18. // Usage: walk all the items in the action palette and record the action set
  19. //        names and all the action children
  20. // Input: <none>
  21. // Return: the array of all the ActionData
  22. // Note: This will throw an error during a normal execution. There is a bug
  23. // in Photoshop that makes it impossible to get an acurate count of the number
  24. // of action sets.
  25. ///////////////////////////////////////////////////////////////////////////////
  26. function GetActionSetInfo() {
  27.         var actionSetInfo = new Array();
  28.         var setCounter = 1;
  29.           while ( true ) {
  30.                 var ref = new ActionReference();
  31.                 ref.putIndex( gClassActionSet, setCounter );
  32.                 var desc = undefined;
  33.                 try { desc = executeActionGet( ref ); }
  34.                 catch( e ) { break; }
  35.                 var actionData = new ActionData();
  36.                 if ( desc.hasKey( gKeyName ) ) {
  37.                         actionData.name = desc.getString( gKeyName );
  38.                 }
  39.                 var numberChildren = 0;
  40.                 if ( desc.hasKey( gKeyNumberOfChildren ) ) {
  41.                         numberChildren = desc.getInteger( gKeyNumberOfChildren );
  42.                 }
  43.                 if ( numberChildren ) {
  44.                         actionData.children = GetActionInfo( setCounter, numberChildren );
  45.                         actionSetInfo.push( actionData );
  46.                 }
  47.                 setCounter++;
  48.         }
  49.         return actionSetInfo;
  50. }


  51. ///////////////////////////////////////////////////////////////////////////////
  52. // Function: GetActionInfo
  53. // Usage: used when walking through all the actions in the action set
  54. // Input: action set index, number of actions in this action set
  55. // Return: true or false, true if file or folder is to be displayed
  56. ///////////////////////////////////////////////////////////////////////////////
  57. function GetActionInfo( setIndex, numChildren ) {
  58.         var actionInfo = new Array();
  59.         for ( var i = 1; i <= numChildren; i++ ) {
  60.                 var ref = new ActionReference();
  61.                 ref.putIndex( gClassAction, i );
  62.                 ref.putIndex( gClassActionSet, setIndex );
  63.                 var desc = undefined;
  64.                 desc = executeActionGet( ref );
  65.                 var actionData = new ActionData();
  66.                 if ( desc.hasKey( gKeyName ) ) {
  67.                         actionData.name = desc.getString( gKeyName );
  68.                 }
  69.                 var numberChildren = 0;
  70.                 if ( desc.hasKey( gKeyNumberOfChildren ) ) {
  71.                         numberChildren = desc.getInteger( gKeyNumberOfChildren );
  72.                 }
  73.                 actionInfo.push( actionData );
  74.         }
  75.         return actionInfo;
  76. }


  77. ///////////////////////////////////////////////////////////////////////////////
  78. // Function: ActionData
  79. // Usage: this could be an action set or an action
  80. // Input: <none>
  81. // Return: a new Object of ActionData
  82. ///////////////////////////////////////////////////////////////////////////////
  83. function ActionData() {
  84.         this.name = "";
  85.         this.children = undefined;
  86.         this.toString = function () {
  87.                 var strTemp = this.name;
  88.                 if ( undefined != this.children ) {
  89.                         for ( var i = 0; i < this.children.length; i++ ) {
  90.                                 strTemp += " " + this.children[i].toString();
  91.                         }
  92.                 }
  93.                 return strTemp;
  94.         }
  95. }
  96. //////////
  97. function CreateSnapshot(name) {
  98.    function cTID(s) { return app.charIDToTypeID(s); };
  99.     var desc = new ActionDescriptor();
  100.     var ref = new ActionReference();
  101.         ref.putClass( cTID('SnpS') );
  102.     desc.putReference( cTID('null'), ref );
  103.         var ref1 = new ActionReference();
  104.         ref1.putProperty( cTID('HstS'), cTID('CrnH') );
  105.     desc.putReference( cTID('From'), ref1 );
  106.     desc.putString( cTID('Nm  '), name);
  107.     desc.putEnumerated( cTID('Usng'), cTID('HstS'), cTID('FllD') );
  108.     executeAction( cTID('Mk  '), desc, DialogModes.NO );
  109. }
  110. //////////
  111. res ="dialog { \
  112. text:'重复执行选定动作',\
  113.         group: Group{orientation: 'column',alignChildren:'left',\
  114.                 corrdination: Panel { orientation: 'row', \
  115.                         text: '选择动作', \
  116.                                 cla: Group { orientation: 'row', \
  117.                                         d: DropDownList {  alignment:'left' },\
  118.                                         }\
  119.                                 act: Group { orientation: 'row', \
  120.                                         d: DropDownList {  alignment:'left' },\
  121.                                         }\
  122.                                 },  \
  123.                                 num: Group { orientation: 'row', \
  124.                                                                         s: StaticText { text:'执行次数:' }, \
  125.                                                                         e: EditText { preferredSize: [50, 20] } ,\
  126.                                                                         }, \
  127.                                 Snapshot:Group{ orientation: 'row', \
  128.                                                                         c: Checkbox { preferredSize: [16, 16]} ,\
  129.                                                                         s: StaticText {text:'建立快照(根据动作内容适当选择)'},\
  130.                                                                         }, \
  131.                                 },\
  132.         buttons: Group { orientation: 'row', alignment: 'right',\
  133.                 Btnok: Button { text:'确定', properties:{name:'ok'} }, \
  134.                 Btncancel: Button { text:'取消', properties:{name:'cancel'} } \
  135.                 } \
  136. }";
  137.        
  138. win = new Window (res);
  139.        
  140.         GlobalVariables();
  141.         var actionInfo = GetActionSetInfo();

  142.         var ddSet=win.group.corrdination.cla.d;
  143.         var ddAction=win.group.corrdination.act.d;

  144.         if ( actionInfo.length > 0 ) {
  145.                 for ( var i = 0; i < actionInfo.length; i++ ) {
  146.                         ddSet.add( "item", actionInfo[i].name );
  147.                 }
  148.                 ddSet.items[0].selected = true;
  149.                 ddSet.onChange = function() {
  150.                         ddAction.removeAll();
  151.                         for ( var i = 0; i < actionInfo[ this.selection.index ].children.length; i++ ) {
  152.                                 ddAction.add( "item", actionInfo[ this.selection.index ].children[ i ].name );
  153.                         }
  154.                         if ( ddAction.items.length > 0 ) {
  155.                                 ddAction.items[0].selected = true;
  156.                         }
  157.                         ddSet.helpTip = ddSet.items[ ddSet.selection.index ].toString();
  158.                 }
  159.                 ddSet.onChange();
  160.         } else {
  161.                 ddSet.enabled = false;
  162.                 ddAction.enabled = false;
  163.         }
  164.        
  165.         ddAction.onChange = function() {
  166.                 ddAction.helpTip = ddAction.items[ ddAction.selection.index ].toString();
  167.         }
  168.        

  169. win.buttons.Btncancel.onClick = function () {
  170. this.parent.parent.close();
  171. }
  172. win.buttons.Btnok.onClick = function () {
  173.         g=Number(win.group.num.e.text);
  174.         if(g<1){
  175.         alert ('-_-!!! 至少得运行一次吧?')
  176.         win.group.num.e.text='1';
  177.         g=1
  178.         }else {
  179.                 var b=win.group.Snapshot.c.value;               
  180.                 if(b && app.documents.length) {CreateSnapshot(g+"遍动作执行前");} //安全起见,建立快照
  181.                 for(i=0;i<g;i++){
  182.                 doAction(ddAction.selection,ddSet.selection) //执行选择的动作
  183.                 }
  184.                 this.parent.parent.close();
  185.         }
  186. }


  187. win.center();
  188. win.show();
复制代码

[ 本帖最后由 mzbx8888 于 2008-2-22 09:02 编辑 ]
租服务器,上51IDC | [长沙]招聘:PHP经理10K/WEB前端6K/PHP开发6K

使用道具 举报

帖子
857
体力
1689
威望
7
发表于 2008-2-21 21:37:04 |显示全部楼层


有点理解

稍稍试了一下...
附件: 你需要登录才可以下载或查看附件。没有帐号?注册

使用道具 举报

文刀

高级会员

帖子
417
体力
1371
威望
0
居住地
山东省 临沂市
发表于 2008-2-21 21:42:47 |显示全部楼层
很方便啊,对动作稍懂一点,对脚本是一窍不通.看那些代码好像看天书!
你有什么不开心的事? 说出来让大家开心一下.

使用道具 举报

我爱蓝色

荣誉管理 手机认证 

帖子
3000
体力
14970
威望
51
居住地
广东省 广州市
发表于 2008-2-21 22:02:27 |显示全部楼层
嘿嘿,恭喜你,第二个脚本又诞生了,测试OK
技术+创意+审美+细心=设计成功的法宝

使用道具 举报

xiexienila 楼主
帖子
1204
体力
1923
威望
41
发表于 2008-2-22 09:23:29 |显示全部楼层

谢谢大家,再来两个简单的例子,希望有所启发





实话说,几个调用的函数都看不大懂,尤其是那个建立快照,更是不知所云。唉 ~

[ 本帖最后由 xiexienila 于 2008-2-22 09:30 编辑 ]
附件: 你需要登录才可以下载或查看附件。没有帐号?注册

使用道具 举报

帖子
71
体力
134
威望
0
居住地
江苏省 南京市
发表于 2008-2-22 10:26:35 |显示全部楼层
非常不错的东东,收藏了。谢谢楼主。
www.seo56.com

使用道具 举报

帖子
10605
体力
3181
威望
23
发表于 2008-2-24 07:24:29 |显示全部楼层
这个好东西 要感谢楼主! 顺便100遍啊100遍。。。
bbs.blueidea.com/thread-2984846-11-1.html thread-2988352-3-1

使用道具 举报

丁丁猫猫

中级会员

帖子
138
体力
259
威望
0
发表于 2008-3-4 10:26:25 |显示全部楼层
提示说cs3才能用

使用道具 举报

myok 

蓝泊湾

银牌会员

帖子
69
体力
1965
威望
0
居住地
山东省 青岛市
发表于 2008-3-4 11:03:25 |显示全部楼层
看着很不错,我也装进去了,为什么提示说错误呢

使用道具 举报

xiexienila 楼主
帖子
1204
体力
1923
威望
41
发表于 2008-3-4 11:07:04 |显示全部楼层
  可能只有高版本的才能用吧

使用道具 举报

帖子
41
体力
116
威望
0
发表于 2008-3-28 22:25:43 |显示全部楼层
怎么能做出渐变的描边的效果呢,自己琢磨半天也弄不出来

使用道具 举报

杨宁

中级会员

帖子
127
体力
317
威望
0
居住地
江苏省 常州市
发表于 2008-3-29 10:06:23 |显示全部楼层
在PS7.0中找不到预置\ 脚本。
通常情况下做一个动作后,按一下只能执行一次动作。如果没有脚本的情况下,可把动作复制N个选定后执行。一个笨办法!

使用道具 举报

wonton 

馄饨

荣誉管理

帖子
6131
体力
15919
威望
105
居住地
浙江省 杭州市
发表于 2008-3-29 10:11:06 |显示全部楼层

回复 #13 yangning 的帖子

7.0 据说也不能用这个脚本
发帖前请搜索,回帖前请仔细看清楼上每一层。大家的批评意见要虚心接受。有错误要积极承认。 论坛的交流气氛要和谐!内容重复和无实际意义的帖子要少发。

使用道具 举报

帖子
69
体力
151
威望
0
居住地
江苏省 苏州市
发表于 2008-3-29 13:44:44 |显示全部楼层
我太崇拜你了!

使用道具 举报

帖子
15
体力
43
威望
0
居住地
广西壮族自治区 桂林市
发表于 2008-5-17 09:22:40 |显示全部楼层
怎么会提示错误啊?

使用道具 举报

lxgm 
帖子
1
体力
12
威望
0
居住地
天津市 南开区
发表于 2008-6-25 12:09:26 |显示全部楼层
楼主您太牛了,小弟领教了.

使用道具 举报

帖子
1
体力
12
威望
0
居住地
河南省 郑州市
发表于 2008-9-17 11:35:07 |显示全部楼层

太牛了,我可能暂时还学不会

使用道具 举报

xkang 
帖子
848
体力
2432
威望
1
发表于 2008-9-26 17:28:37 |显示全部楼层
pS越来越强大了
因为专业,所以选择..技术群:11162579

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

Archiver|手机版|安久科技提供CDN|blueidea.com ( 京ICP备05002321号 )  

GMT+8, 2012-2-13 09:13 , Processed in 0.133139 second(s), 9 queries , Gzip On, Memcache On.

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部