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

THEME_COLOR

Guide ,
Jun 13, 2017 Jun 13, 2017

Copy link to clipboard

Copied

Hi all,

sorry for the cross posting from Illustrator Scripting, but this might be also interesting around here.

The following works with InDesign and Illustrator.

function main()

{

  var palette = this.palette = new Window("""palette""");

  var graphics = palette.graphics;

  $.writeln("Brush:");

  var colors = ["background","disabledBackground","selection","focusRing"];

  while( colors.length ) {

    var name = colors.pop();

    $.writeln(name," = ",graphics.newBrush(graphics.BrushType.THEME_COLOR,name).color.toSource());

  }

  $.writeln();

  $.writeln("Pen:");

  var colors = ["foreground","disabledForeground","selection"];

  while( colors.length ) {

    var name = colors.pop();

    $.writeln(name," = ",graphics.newPen(graphics.PenType.THEME_COLOR,name,1).color.toSource());

  }

  $.writeln();

}

main();

Regards,

Dirk

TOPICS
Scripting

Views

836

Translate

Translate

Report

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
Guru ,
Jun 13, 2017 Jun 13, 2017

Copy link to clipboard

Copied

Fantastic Dirk!, much better than the pathetic hacks we've been using for the past years, brilliant.

Thanks

Trevor

P.s. not sure why you are using triple quotes and this

var palette = this.palette = new Window("""palette""");

and not

var palette = new Window("palette"); 

Any light on that?

Votes

Translate

Translate

Report

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
Guide ,
Jun 14, 2017 Jun 14, 2017

Copy link to clipboard

Copied

> why triple quotes

My sloppiness. That line was lifted from a member function in an Illustrator script where I used multi-line resource notation to build the palette and contained widgets. "this" stores the palette in my namespace object - AFAIK Illustrator only supports one target engine so I try to stay away from globals.

Votes

Translate

Translate

Report

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
Guru ,
Jun 14, 2017 Jun 14, 2017

Copy link to clipboard

Copied

Actually there's at least 2 engines in Illustrator with "main" and "transient" being the standard ones.

Votes

Translate

Translate

Report

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 ,
Jun 14, 2017 Jun 14, 2017

Copy link to clipboard

Copied

Hi Trevor,

I'm not so much into Illustrator scripting.


What is the version of AI where you  see this "transient" engine?
Currently I cannot check—I'm on a older OS X for developing a script for InDesign CS4 and have two different ESTKs open—where my ESTK that can target CS6 and CC is showing only "main" when connected to AI CC 17.1.0.

Would "transient" work with the typical:

#targetengine "transient"

statement?

Thanks,
Uwe

Votes

Translate

Translate

Report

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
Guru ,
Jun 14, 2017 Jun 14, 2017

Copy link to clipboard

Copied

Hi Uwe

Yes one would target it like that.

I don't know what's the difference between main and transient. It pitched up on my system in CC2015 and is still here for 2017.

I don't know why it's not showing up on yours.

Maybe it's connected to HTML panels I've done.

When one creates an HTML panel it will create it's own workspace.

You can have

csInterface.evalScript("foo='bar'");

csInterface.evalScript("alert(foo)"); // bar

but when you try foo from either the main or transient engines you get the undefined error.

On Illustrator the engines "invisible" which means you won't see it on the ESTK

I think by default in InDesign it's visible and you will see it.

From the little I know about SDK when you create an engine you chose if you want the engine to be visible or not.

Either way I can't but help repeat how impressed I am with Dirk's snippet, this problem has been going around the InDesign and Illustrator developers for years.

Votes

Translate

Translate

Report

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 ,
Jun 14, 2017 Jun 14, 2017

Copy link to clipboard

Copied

Trevorׅ  wrote

… Yes one would target it like that.

I don't know what's the difference between main and transient. It pitched up on my system in CC2015 and is still here for 2017.

I don't know why it's not showing up on yours.

Now, that I can explain. My old system is not able to run CC 2014, 2015 and 2017.

And yes, Dirk always impresses me much!
I literally wasted hours over hours with Pen and Brush in ScriptUI before I discovered, that Dirk had a solution somewhere waiting on the web. So my big thanks go to Dirk!

Regards,
Uwe

Votes

Translate

Translate

Report

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
Guide ,
Jun 14, 2017 Jun 14, 2017

Copy link to clipboard

Copied

Uwe, Trevor,

thanks, actually that solution was only posted yesterday.

Some more notes:

The key list should be exhaustive for the palette widget of a current InDesign, but I did not yet dig into any other widgets or applications. As the list worked for Illustrator I also did not look for other/more values there.

My main motivation was to determine the current dark/bright UI setting in order to choose a matching icon, unfortunately I found no Illustrator equivalent to InDesign's app.generalPreferences.uiBrightnessPreference so I now check the background color value.

These theme colors are dynamic - always grab a new instances of the same brush or pen, the table is updated when the user adjusts the preference. Maybe we can catch those events with some custom draw widget?

Dirk

Votes

Translate

Translate

Report

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
Guru ,
Jun 14, 2017 Jun 14, 2017

Copy link to clipboard

Copied

Hi Dirk,

Events are very tough on Illustrator.

The only way that I can think of that might (15% ?) work on the jsx engine is using the archaic object "watch", linking it somehow to the brush object.

I once tried something like that but can't remember if I got it to work, although I think I might of I could very well be wrong (85% ?).

Other than that if your out of the jsx engine which knowing you, you probably are then you could poll the property in an imitation of an idle event.

In fact I just remembered that CSInterface.js has methods for retrieving UI skins info maybe those will be helpful.

HTH

Trevor

Votes

Translate

Translate

Report

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
Guru ,
Jun 14, 2017 Jun 14, 2017

Copy link to clipboard

Copied

LATEST

line 477

CSInterface.THEME_COLOR_CHANGED_EVENT = "com.adobe.csxs.events.ThemeColorChanged";

Looks promising

Votes

Translate

Translate

Report

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
People's Champ ,
Jun 14, 2017 Jun 14, 2017

Copy link to clipboard

Copied

Nice !!

Votes

Translate

Translate

Report

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