Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

ScriptUI reference?

Guest
Sep 14, 2010 Sep 14, 2010

I still havn´t really figured ScriptUI out. From what i have understood its used for all adobe software to make the interfaces. And i guess thats why i cant find much reference in the indesign pdfs.

There seem to be three different ways of coding a dialog:

var myDlg = new Window('dialog', 'test');

myDlg.add('staticText', undefined, 'Test');

myDlg.show();

---

var myDlg = app.dialogs.add({name:"Test"});

with(myDlg.dialogColumns.add()) {

staticTexts.add({staticLabel:"Test"});

}

myDlg.show();

---

var myDlg = new Window("dialog { \

test: StaticText { text: 'Test' } \

}");

myDlg.show();

---

They all give prety much the same result, I prefer the first one.

The problem I had right now was that when I add some checkboxes to a dialog they all stack on top of each other, but when i put them in a group, they float left like CSS float: left.

But the big question is if there is a good reference so i can find it my self?

TOPICS
Scripting
6.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 14, 2010 Sep 14, 2010

The samples in the Javascript Tools Guide (on the Adobe site, in Scripting Resources) contain small snippets of code, which have helped me out in the few stints I had with ScriptUI.

The Definitive Reference is to all commands is inside the ESTK itself (look under the Help Window), but you could try my version of the same information: http://www.jongware.com/idjshelp.html. Either download the ScriptUI Help as a file on its own, or go for the complete CS4/CS5 guides, as the ScriptUI classes are integrated into those and they contain tons of other goodies.

To comfortably view, browse and search these files, you don't need anything special on Windows (this comes with a CHM viewer). On a Mac you can try any dedicated "Windows CHM Viewer for OSX" -- there are a few but I provide a link to my favorite, Robin Lu's iCHM, near the bottom of that web page.

Oh -- and there are three ways of creating dialogs but you used the same one twice

The 'old' one is using app.dialogs, which is great to quickly write a simple interface, and the new one -- ScriptUI -- is the stuff called up with "app.windows.add", and can be used to create a panel or dialog nigh-on indistinguishable from InDesign's own. It's just that there are a few ways of creating windows with them -- element by element, or the whole package in one long string. They don't differ in how they work.

The third way, by the way, is writing a dialog entirely in Flash (which I haven't used as yet -- anyway, since you also have to call it into existence through a ScriptUI windows, it's sort of a two-and-a half way, rather than something different again).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 14, 2010 Sep 14, 2010

The third way, by the way, is writing a dialog entirely in Flash (which I haven't used as yet -- anyway, since you also have to call it into existence through a ScriptUI windows, it's sort of a two-and-a half way, rather than something different again).

A fourth way (or third and a half) is using the CS SDK in CS5 to create flash panels and dialogs. They do not use Script UI or InDesign Scripting dialogs at all.

Of course if you use AppleScript or VB, you can use the system-specific dialogs as well.

Some people even use outside apps built in REALBasic or some other language (you could do it in AIR for example)...

Harbs

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 14, 2010 Sep 14, 2010

The official reference is the "Javascript Tool Guide.pdf", which can be accessed from the extendscript toolkit. It is under the Help menu.

Pontus Uggla wrote:

var myDlg = app.dialogs.add({name:"Test"});

with(myDlg.dialogColumns.add()) {

staticTexts.add({staticLabel:"Test"});

}

myDlg.show();

This is InDesign specific dialog and not ScriptUI

Pontus Uggla wrote:

var myDlg = new Window('dialog', 'test');

myDlg.add('staticText', undefined, 'Test');

myDlg.show();

---

var myDlg = new Window("dialog { \

test: StaticText { text: 'Test' } \

}");

myDlg.show();

The first way is the preferred way, the second way is using resource string which has its limitations. Besides, resource strings are hard to write, read & debug, making them undesirable.

There are a few bugs in ScriptUI where you need to make some use of resource strings, but that is for a different time.

As a side point. In javascript any object can be constructed with resource strings. This is commonly used for the "properties" property in the InDesign DOM, where multiple properties of object are set using resource strings. So Adobe didn't really implement 2 ways, but rather you have 2 ways to create a dummy object and feed it into ScriptUI to do its magic.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Sep 15, 2010 Sep 15, 2010

I recommend you to download Bridge CS3 SDK -- it contains several examples of Script UI with detailed description: SnpCreateDialog.jsx,  SnpCreateDynamicScriptUI.jsx, SnpCreateTabbedPaletteScriptUI.jsx, SnpCreateTreeView.jsx, SnpCreateUIAddMethod.jsx and others.

AlertBoxBuilder1.jsx, for example, demonstrates how to build a dialog box that contains all UI elements. It's much easier to run an example script at first and then read manuals, references, script's comments, etc. to figure out how it works.

For some reason CS5 SDK doesn't include these examples.

Kasyan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 15, 2010 Sep 15, 2010

Hi Kasyan,

The scripts you mention are installed by default with the ESTK.I forget where exactly (I moved them away from their deeply nested folder to a more accessible place for easier reference), but if you search your disk for one of the script names you'll get there.

Peter

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Sep 15, 2010 Sep 15, 2010

Yeah! Peter is right!

You can find files in ESTK folder.

Win 7: c:\Program Files (x86)\Adobe\Adobe Utilities\ExtendScript Toolkit CS4\SDK\Samples\javascript\

Win XP: c:\Program Files\Adobe\Adobe Utilities\ExtendScript Toolkit CS4\SDK\Samples\javascript\

--

tomaxxi

http://indisnip.wordpress.com/

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Sep 15, 2010 Sep 15, 2010
LATEST

Thanks for the tip, but I am still on CS3, so they are not there.

Kasyan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines