Skip to main content
Participant
October 16, 2008
Question

SDK vs SCRIPT - GENERAL QUESTION

  • October 16, 2008
  • 9 replies
  • 1306 views
Hi,
I am automation developer for all Adobe products using JavaScript, VBScript. Now I am looking SDK development.

Can I use VBScript code inside of SDK. I mean, I use VBScript (code) which is much meaning full. But C++ code is not like that.

For clear, We can use (Javascript, VBScript, AppleScript) for scripting. Can we use either this instead C++ code for SDK?
This topic has been closed for replies.

9 replies

Participating Frequently
October 21, 2008
Hi,

Usually you'll use DollyXs to create projects for plug-ins, both Windows and Mac. There's a document called ww-plugins.pdf that will tell you everything about it. It's located in [CS3SDK]/docs/guides.

You'll also find a lot of other documentation there which is a really important resource for you as you learn how to develop with the SDK. Browse through the programming-guide.pdf, and pay extra attention to the first 7 chapters that will tell you generally how to integrate with InDesign.

The remaining chapters are more targeted on specific areas, and may be less important for you depending on what your solution is supposed to do. They are interesting reads though.

And don't forget to look and search in the reference for specific issues in [CS3SDK]/docs/reference/index.chm. For instance, look up IScriptRunner in there.

/Andreas
Participant
October 21, 2008
Thanks for enlighten me,

I ought to build tool for both platform (WIN & MAC).
I am using X code for Mac. It's work fine. When I create new "Project", I able to get InDesign Project\SDK Project.

But in Windows I able to build only sample project in VS2005. I unable to create my own, like Acrobat. Because I have Acrobat SDK also (Acro8PIWiz as template).

Thanks once again,
Saravanan.K
Participating Frequently
October 20, 2008
Hi Saravanan.<br /><br />The RunFile method is used to execute a file containing a script. To execute a string with the script in, you'll have to use RunScript instead.<br /><br />For instance, to execute an ExtendScript inside of InDesign, to show the document name:<br /><br />InterfacePtr<IScriptManager> scrMgr(<br /> Utils<IScriptUtils>()->QueryScriptManager(kJavaScriptMgrBoss));<br />InterfacePtr<IScriptRunner> scrRun(scrMgr, UseDefaultIID());<br /><br />PMString pmMyScript("alert(app.activeDocument.name);");<br />oleScrRun->RunScript(pmMyScript);<br /><br />As Patrick says, this is also pretty easy to do with pure API calls as well. However, even though I would suggest learning the API, there's no ideal solution that can be applied to all situations. Sometimes, hybrid solutions may be the best to combine the power the API gives you with the flexibility and ease of development that scripting brings.<br /><br />/Andreas
Known Participant
October 20, 2008
The answer is still the same: SDK is not leading you to scripting statements but to compiled binaries and the C++ compiler will never understand VC or JS or AS syntax.

To get front document's name look at IDocument API in SDK documentation. To display this document's name look at CAlert class.

How to get IDocument for current document or how to display a message using CAlert are shown many times in SDK sample projects: if this is really all you need to go ahead then it should be a cake walk.

Best regards

Patrick Perroud
Participant
October 20, 2008
Thanks a lot those involving to answer.<br />Now, I have decided to go with SDK. Look at this :<br /><br />InterfacePtr<IScriptRunner> scrRun(<br /> Utils<IScriptUtils>()->QueryScriptRunner(scriptFile));<br />scrRun->RunFile(scriptFile);<br /><br />Instead "scriptFile" object, can I write my script inside as text like <br />scrRun->RunFile("alert("I am working");.....");<br />Sorry, if this question is stupid.<br /><br />I am so confusing about the bunch of files inside of every single sample project. Could you please guide me how to display the Active Document name. I hope, I can develop everything on that..<br /><br />Thanks<br /><br />Saravanan.
JADarnell
Inspiring
October 16, 2008
Hello ksaravanan:

After reading your request several times I think you are asking this: Can an InDesign script do the same thing as what can be done using the SDK?

I have written a fairly complex Applescript program which is used to generate fairly large and complex documents from an inhouse scripting language--the scripting required macro expansion, macro substitution, and complex analysis involving deep nesting and careful logic. I did a lot of complex stuff, and I could have done every single one of those selfsame tasks in a plugin using the InDesign SDK. Further, those tasks would have been done faster and probably more efficiently using SDK code. Why Applescript? To be honest (grin) my boss knew I was a Windows man and he wanted to see me work on a Mac out of pure spite (wide grin).

But I also convinced him that everything this converter needed to do could be done using Applescript a lot more simply and quickly than in an SDK. Speed was not an issue, nor was efficiency. Development time was (even so it still took me about a year to develop).

Now, can everything done by the SDK be done in a script? No. Not by a long shot. Oh, I suppose one could write a plugin and make it scriptable; in that sense, yes, but in every other sense, no. The SDK gives the programmer pretty deep access to the innards of the program; script commands hide such access
b (see Patrick Perroud's fine entry--Patrick, that was poetry, my friend)
. So it depends upon what you want to do. Simple automation or even complex automation that doesn't often change and does not require speed can probably be handled just fine by a script. If you need speed, efficiency, and/or if you need to reach into the heart of InDesign, learn the SDK. It's a challenge, but worth it.

HTH!

John
October 16, 2008
SDK -- You develop something based on SDK

Script -- You use your or other people's program that are already developped.
Known Participant
October 16, 2008
I have even a shorter answer: "no way" - C++ is not only SDK programming language but also its core architecture.

If you feel more at ease with scripting languages why would you need to execute a script from a plugin?

(well - I know a few answers and even commited a few plugins that are doing this but this is hardly answering your topic in this forum IMO).

Better make your own choice: keep going your usual scripting ways or switch to SDK - but expecting that SDK would use same level of automation than scripting is quite misunderstanding SDK to me.

If you are serious about SDK then you'll have to follow its rules like all of us - and this means going much deeper than you could ever expect possible only doing scripting automation: C++ is only a minor issue with SDK.

More than a language to learn SDK is a way of thinking and only practice will make it more familiar to you: SDK is not a framework to automate InDesign - it's what InDesign is made about.

Therefore instead of telling you a plugin could run any script - which is obviously true - I'll encourage you to persist in this direction and not get discouraged at the difficulty: the result is worth it.

Best regards

Patrick Perroud
Participating Frequently
October 16, 2008
Hi!<br /><br />Short answer: Yes. You can execute script from within a plug-in.<br /><br />To do this, you have to get the correct IScriptRunner for the scripting language you want to execute and then call either IScriptRunner::RunFile or IScriptRunner::RunScript.<br /><br />You have to get the IScriptRunner interface for the script language that you want to execute. For VBScript you would have to do something like:<br /><br /><tt>InterfacePtr<IScriptManager> oleScrMgr(<br /> Utils<IScriptUtils>()->QueryScriptManager(kOLEAutomationMgrBoss));<br />InterfacePtr<IScriptRunner> oleScrRun(oleScrMgr, UseDefaultIID());<br />oleScrRun->RunScript(pmMyScript);</tt><br /><br />If you have a file containing the script, you can use IScriptUtils to give you the correct IScriptRunner directly:<br /><br /><tt>InterfacePtr<IScriptRunner> scrRun(<br /> Utils<IScriptUtils>()->QueryScriptRunner(scriptFile));<br />scrRun->RunFile(scriptFile);</tt><br /><br />The available script bosses are:<br /><br />* <tt>kOLEAutomationMgrBoss</tt><br />* <tt>kAppleScriptMgrBoss</tt><br />* <tt>kJavaScriptMgrBoss</tt><br /><br />/Andreas