获取使用Objective-C Photoshop的动作列表 [英] Get Photoshop's action list using Objective-C
问题描述
我使用C ++和对象 - 这与Photoshop交互写OSX的应用程序。
I'm writing an application for OSX using C++ and Obj-C that interacts with Photoshop.
我一直在使用 NSAppleScript
与动态生成的AppleScript驱动的Photoshop(是的,这是一个有点吓人......)我很想能够驱动的Photoshop不同的方式,因此,如果有人知道一个更好的方式,我接受它!不幸的是,我不能使用 ScriptingBridge
我可以不打领带我的用户到Leopard。
I've been using NSAppleScript
with dynamically built AppleScripts to drive Photoshop (yes, it's a little scary...) I would love to be able to drive Photoshop a different way, so if anyone knows a better way, I'm open to it! Unfortunately, I can't use ScriptingBridge
as I can't tie my users to Leopard.
最大的问题就在那天晚上来了,当我去从Photoshop查询操作列表中显示给我的用户。显然,Photoshop的脚本集成不公开的操作列表API来的AppleScript。这是第二个原因我不能使用 ScriptingBridge
。
The big problem came just the other night when I went to query the action list from Photoshop to display to my users. Apparently, Photoshop's scripting integration doesn't expose the action list APIs to AppleScript. Which is a second reason why I can't use ScriptingBridge
.
有谁知道一种方法,我可以访问我的OBJ-C / C ++程序Photoshop的动作列表?奖金的问题:?!没有人知道一个更好的办法,我可以用Photoshop进行交互
Does anyone know a way I can access Photoshop's action list in my Obj-C/C++ program? Bonus question: does anyone know a better way I could be interacting with Photoshop?!
推荐答案
不知道如何与AppleScript的做,但你可以调用该JavaScript使用AppleScript在给定的操作列表返回的名字。我采用了这种从图像Processor.jsx。
Not sure how to do it with AppleScript but you can call this JavaScript using AppleScript to return the names in a given action list. I adapted this from "Image Processor.jsx".
function GetActionList(folderName)
{
var setCounter = 1;
var actions = '';
var actionName;
gClassActionSet = charIDToTypeID( 'ASet' );
gClassAction = charIDToTypeID( 'Actn' );
gKeyName = charIDToTypeID( 'Nm ' );
gKeyNumberOfChildren = charIDToTypeID( 'NmbC' );
while ( true )
{
var ref = new ActionReference();
ref.putIndex( gClassActionSet, setCounter );
var desc = undefined;
try { desc = executeActionGet( ref ); }
catch( e ) { break; }
actionName = desc.getString( gKeyName );
var numberChildren = 0;
if ( desc.hasKey( gKeyNumberOfChildren ) )
numberChildren = desc.getInteger( gKeyNumberOfChildren );
if ( numberChildren )
{
if(actionName == folderName)
{
for ( var i = 1; i <= numberChildren; i++ )
{
var ref = new ActionReference();
ref.putIndex( gClassAction, i );
ref.putIndex( gClassActionSet, setCounter );
var desc = undefined;
desc = executeActionGet( ref );
if( desc.hasKey( gKeyName ) )
{
if(actions.length > 0)
actions = actions + ',' + desc.getString( gKeyName );
else
actions = desc.getString( gKeyName );
}
}
break;
}
}
setCounter++;
}
return actions;
}
这篇关于获取使用Objective-C Photoshop的动作列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!