2014-02-22 62 views
1

我正在寫一個Photoshop腳本來打開一些圖像並對它們做一些操作。到現在爲止還挺好。我需要腳本播放以前在Photoshop中記錄的給定的動作從Javascript腳本中運行Photoshop「動作」

如何從Javascript代碼調用和播放Photoshop動作?

I'm尋找類似:

app.actions["actionName"].play() 
app.actions["actionName"].onComplete(function(){/*do stuff when finished*/}) 

(翻譯行動統一到JS代碼是不是我的應用程序的一個選項)

回答

0

運行的動作可以用幫助完成從了Xtools圖書館利用在這裏:http://ps-scripts.sourceforge.net/xtools.html我相信你想看看'ActionEval'文件。至於在動作完成時收到通知 - 我不確定是否播放動作會阻止腳本的執行直到完成。你必須自己測試一下。

1

我相信你正在尋找的代碼是這樣的:

app.doAction("ActionStep","ActionFile.ATN") 

你要去想確保ATN文件已加載到photoshops行動調色板,「ActionStep」的會是在步驟的名稱要運行,而「ActionFile.ATN」是步驟位於操作文件。

,你可以走得更遠一點,甚至在錯誤添加處理

try{ 
//Code you want to execute 
app.doAction("ActionStep","ActionFile.ATN") 
}catch(e){ 
//If Code didn't execute then goes here, and executes code within this block 
...Code... 
}finally{ 
//executes this code immediately after try block, if error is thrown then is executed after catch block This block is optional and is not necessary. 
...Code... 
}