Skip to main content
Mike Witherell
Community Expert
Community Expert
October 7, 2012
Question

Script to click on Stroke and Fill and Swap and Default and ...

  • October 7, 2012
  • 1 reply
  • 5495 views

Hey gang,

I have been playing with configurator 3.1.1 where you can make a button on a toolbar and supply it with a script. I am trying to make a custom toolbar for InDesign CS6. It already includes buttons for all the tools, except for (I am shocked to note) Stroke, Fill, Swap, Default, Apply Color, Apply Gradient, Apply None, and possibly Formatting Affects Container and Formatting Affects Type. I don't know how to command these missing 7-9 parts of the toolbox panel.

My workaround? Use the Configurator Script button, and supply the button with scripting that calls the functional button command. In reading and researching, I found one command: StrokeFillProxyOptions.FILL which presses the Fill Proxy button.

Alas, I don't have the complete picture. That expression alone does not make the whole clickable script button work. Can you help me write the whole line of script code that would make the button click?

Best to you,

Mike Witherell in Maryland

This topic has been closed for replies.

1 reply

Jongware
Community Expert
Community Expert
October 7, 2012

Michael Witherell wrote:

In reading and researching, I found one command: StrokeFillProxyOptions.FILL which presses the Fill Proxy button.

Alas, I don't have the complete picture. That expression alone does not make the whole clickable script button work.

Correct -- it's an Enumeration value, not a command or a setting. See http://jongware.mit.edu/idcs6js/pc_StrokeFillProxySetting.html for where it's applied to. (Actually, backtracking from http://jongware.mit.edu/idcs6js/pe_StrokeFillProxyOptions.html. At the bottom it says "Usage / As property" in 'StrokeFillProxySettings.active', and that in turn is an element of 'Application.strokeFillProxyOptions'. I didn't look up 'Application', pretty sure this one must be 'app'.)

Without trying, I think this should work:

app.strokeFillProxySettings.active = StrokeFillProxyOptions.FILL;

Mike Witherell
Community Expert
Community Expert
October 7, 2012

Aha! That does work when pasted into the configurator button. Thanks so very much!

I edited the end to say STROKE and got the stroke button to fire, as well.

2 down; 5 to go! Is the Default button and the Swap button done in a similar way? What about the 3 Apply buttons underneath?

Best to you,

Mike Witherell in Maryland

Mike Witherell
Jongware
Community Expert
Community Expert
October 8, 2012

One of these other 'proxy' settings is 'target', which seems to be the "Container/Text" toggle button.

As for the three "Apply" buttons: you can find out the current mode (stroke or fill) from this property, then apply the stroke or fill color -- they are also in here.

I don't know about the "gradient" one, it doesn't appear as a category on its own. (Gradients ... do you really care? )

The last one, 'None', can be trivially scripted as

app.selection[0].strokeColor = app.activeDocument.swatches.item("None");

(and the same thing for Fill Color).

The default swatches for fill and stroke can be read and set in pageItemDefaults . These apply to either Application or Document level, I assume one would typically use 'Document' here.