Hello
In SC3, I was able to run javascripts in Indesign using the following code:
// add my arguments
Utils<IScriptArgs>()->Save(); // create new script-args context on the stack
for(int32 i=0; i < paramN.size(); i ++) {
Utils<IScriptArgs>()->Set(paramN[i], paramV[i]);
}
// Get a handle on the ExtendScript Manager
InterfacePtr<IScriptManager> scriptManager(Utils<IScriptUtils>()->QueryScriptManager(kJavaScriptMg rBoss));
if (!scriptManager)
break;
InterfacePtr<IScriptRunner> scriptRunner(scriptManager, UseDefaultIID());
if (! scriptRunner)
break;
scriptRunner->RunScript(scriptStr2);
In CS5, this fails:
InterfacePtr<IScriptRunner> scriptRunner(scriptManager, UseDefaultIID());
if (! scriptRunner)
break;
I have solved the problem by writing the script to a file and using:
InterfacePtr<IScriptRunner> scriptRunner( Utils<IScriptUtils>()->QueryScriptRunner(IDFile(pathToFile));
It works, but I do not want to have to write the script down to file before executing it.
Is there a way around this?
Best regards
/ Pontus
Hi,
I'm not sure but perhaps if you try this :
InterfacePtr<IScriptManager> scriptManager(Utils<IScriptUtils>()->QueryScriptManager(kJavaScriptMg rBoss));
if (!scriptManager)
break;
InterfacePtr<IScriptEngine> scriptEngine(scriptManager->QueryDefaultEngine ());
if (!scriptEngine)
break;
// IScriptRunner aggregate same boss than IScriptEngine
InterfacePtr<IScriptRunner> scriptRunner(scriptEngine, UseDefaultIID());
if (! scriptRunner)
break;
RunScriptParams params(scriptRunner);
scriptRunner->RunScript(scriptStr2,params);
Ludo.
Hello Ludo
I did it your way, and i used QueryDefaultEngine to instansiate an
IScriptEngine, and that seems to do the trick.
Thanks for the help.
Best regards
/ Pontus
szcz007 skrev:
Hi,
I'm not sure but perhaps if you try this :
InterfacePtr<IScriptManager> scriptManager(Utils<IScriptUtils>()->QueryScriptManager(kJavaScriptMg rBoss));
if (!scriptManager)
break;
InterfacePtr<IScriptEngine> scriptEngine(scriptManager-> ());
if (!scriptEngine)
break;
// IScriptRunner aggregate same boss than IScriptEngine
InterfacePtr<IScriptRunner> scriptRunner(scriptEngine, UseDefaultIID());
if (! scriptRunner)
break;
RunScriptParams params(scriptRunner);
scriptRunner->RunScript(scriptStr2,params);
Ludo.
>
Hello
I write the stript to file and then call the following code:
PMString PnlTrvUtils::RunScript(PMString scriptStr2,
K2VectorQueryScriptRunner(IDFile(scriptStr2)));
if (! scriptRunner)
RunScriptParams params(scriptRunner);
scriptRunner->RunFile(IDFile(scriptStr2), params);
// extract result
/*
for(int32 j = 0; j Restore();
} while(false);
return "";
}
Best regards
/ Pontus
JohnAnt185 skrev:
>
Re: RunScript in CS5 and CS4? How do I set up RunScriptParams
created by JohnAnt185 <http://forums.adobe.com/people/JohnAnt185> in
/InDesign SDK/ - View the full discussion
North America
Europe, Middle East and Africa
Asia Pacific