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

app.executeMenuCommand() problems

Valorous Hero ,
Feb 09, 2017 Feb 09, 2017

Copy link to clipboard

Copied

I'm using AI CC 2017 and it has been brought to my attention that my app.executeMenuCommand("doc-color-cmyk"); doesn't work some times when my script is ran.

#target illustrator

function test(){

    var doc = app.activeDocument;

    app.executeMenuCommand("doc-color-rgb");

    app.redraw();

};

test();

I tested the above snippet and sure enough, nothing happens.

Then, I went to the menu item and hovered over it to reveal the CMYK/RGB menu items in the document color space (without choosing one even), and it now works.

Is this the same thing that's happening with the Actions not registering the recorded scripts menu items?

It is not acceptable when they have to show this item, however rare it might be!

I went by with actions for this purpose, but having this come up was a rather unwelcome 'surprise'.

TOPICS
Scripting

Views

2.2K

Likes

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 ,
Feb 09, 2017 Feb 09, 2017

Copy link to clipboard

Copied

it works ok here. Windows 10, CC2017

Likes

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
Valorous Hero ,
Feb 09, 2017 Feb 09, 2017

Copy link to clipboard

Copied

Did you try restarting your Illustrator and not revealing the document color space menu item and running the test?

Likes

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 ,
Feb 09, 2017 Feb 09, 2017

Copy link to clipboard

Copied

that's correct, I tried a couple times on a newly restarted illustrator session.

Likes

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
Valorous Hero ,
Feb 09, 2017 Feb 09, 2017

Copy link to clipboard

Copied

Well, maybe it's just a Mac thing.

Likes

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
Valorous Hero ,
Feb 09, 2017 Feb 09, 2017

Copy link to clipboard

Copied

Aha! Try this. Save yourself a CMYK document with at least one piece of CMYK art in it.

Then restart, and open it up. Try to execute the menu command - it's not going to work, I bet!

Maybe it thinks this is a lot of effort when there's some art inside, but it's got no problem with a blank document.

And of course, mousing over the color space menu item has an immediate cure effect.

(It's going to blow your mind, I am not crazy, I am not .. crazy)

Likes

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 ,
Feb 09, 2017 Feb 09, 2017

Copy link to clipboard

Copied

lost the bet...still works fine.

Likes

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 ,
Feb 09, 2017 Feb 09, 2017

Copy link to clipboard

Copied

I'm running your test() from the estk

Likes

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
Valorous Hero ,
Feb 09, 2017 Feb 09, 2017

Copy link to clipboard

Copied

Well, I may sound like a madman - even to myself now, because I tried it now 4 times, 1st time successful and the rest not.

Likes

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 ,
Feb 09, 2017 Feb 09, 2017

Copy link to clipboard

Copied

you're a mad man, let me try 3 more times

Likes

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
Valorous Hero ,
Feb 09, 2017 Feb 09, 2017

Copy link to clipboard

Copied

This is but my file, which I made just now and it's defying me even as we speak!

Screen Shot 2017-02-10 at 1.02.07 AM.png

By the way, I'm on 21.0.1  and this is definitely happening on Macs. My OS is El Captain.

Likes

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 ,
Feb 09, 2017 Feb 09, 2017

Copy link to clipboard

Copied

...still worked fine everytime

cmyktorgb.PNG

Likes

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
Valorous Hero ,
Feb 09, 2017 Feb 09, 2017

Copy link to clipboard

Copied

Ha I shall try on Windows in the morning. Maybe it's why it's gone unnoticed for a while now.

Likes

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 ,
Feb 09, 2017 Feb 09, 2017

Copy link to clipboard

Copied

Hi Silly,

Your code completely works fine in my El Captan.

スクリーンショット 2017-02-10 16.44.44.png

Likes

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
Valorous Hero ,
Feb 10, 2017 Feb 10, 2017

Copy link to clipboard

Copied

stock-vector-crazy-cartoon-guy-in-a-straight-jacket-vector-illustration-with-simple-gradients-all-in-a-single-106320659.jpg

Is it just me?

I just tried same on my Windows (7) AI CC0217 21.0.2 (I swear I get the latest updates, how is my Mac one only 21.0.1?)
And guess what, same thing!

Maybe it has to do with creating a document that starts with the "Print" profile?

I literally made a new CMYK .ai doc, saved it, closed my AI, re-opened it, ran the script and get my result.

UPDATE:
Hey, I realized that it doesn't necessarily have to do with explicitly revealing the Document Color Mode menu items, but rather the fact that Document Color Mode menu items are grayed out when you first open Illustrator and either create new or open an existing document.

Before a document is open, the menu items are disabled. So, I open a document and the menu disappears, the new document opens and the script does not work.

However, the very next time I open a document or create a new one, since there is an open document, the menu items are enabled. The script will work henceforth. Try it!

You don't even have to restart Illustrator each time, just get to where no documents are open and try this test. (And by "no documents are open", I mean, have no documents open and then create or open one)

Likes

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 ,
Feb 10, 2017 Feb 10, 2017

Copy link to clipboard

Copied

Hi Silly-V

it works ok here. Windows 10, 21.0.2

running more than 5 times with open, script, close, reopen,open, script, close file, close app, reopen …

(always running the script from file menu in Illu)

Likes

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
Valorous Hero ,
Feb 10, 2017 Feb 10, 2017

Copy link to clipboard

Copied

Oh, yea - don't run from the file menu but run it from ESTK.

Running from file menu will ruin it because you're exposing the file menu.

My script ran from bridgetalk palette so there was not a chance to expose the file menu and see the enabled color space menu item.

Likes

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 ,
Feb 10, 2017 Feb 10, 2017

Copy link to clipboard

Copied

Running directly from estk makes no difference for me. All works ok.

One shot into the dark:

Do you have more Illu versions parallel on your computer?

Did you try to target the correct version

#target illustrator-21

Likes

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
Valorous Hero ,
Feb 10, 2017 Feb 10, 2017

Copy link to clipboard

Copied

No, and it does the same on my mac and windows.

Did you make sure to start with no documents open, then open a document and then never touch the file menu again but run the script from ESTK?

Likes

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 ,
Feb 10, 2017 Feb 10, 2017

Copy link to clipboard

Copied

yupp

Likes

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
Valorous Hero ,
Feb 10, 2017 Feb 10, 2017

Copy link to clipboard

Copied

hmmm thanks

Likes

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
Engaged ,
Feb 12, 2017 Feb 12, 2017

Copy link to clipboard

Copied

Silly-V, did you try make an action and run it through script? What will be action behaviour?

Perhaps the bug bound with third party software? Doubtful, but probable.

What the same software (like keyboard switchers that may generate some funny and strange bugs) in your Mac and Windows?

Likes

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
Valorous Hero ,
Feb 12, 2017 Feb 12, 2017

Copy link to clipboard

Copied

Yes, I used actions as a successful work-around. Also in my last test, I did have to explicitly reveal the Document Color Mode menu items with the disclosure triangle to make the code work - whereas in a previous test I had to reveal the File menu only.

One more thing: on both computers I have ever tested this on (one windows one mac) they each have a setup with 2 monitors.

Likes

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
New Here ,
Sep 23, 2021 Sep 23, 2021

Copy link to clipboard

Copied

is this issue solved,I am in Illustrator 2021 and this issue happen in Mac with M1,but OK in Win10

Likes

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 Beginner ,
Oct 04, 2022 Oct 04, 2022

Copy link to clipboard

Copied

LATEST

I have had the same problem with Illustrator 26 / windows 10 tying to run a script to batch convert some files to CMYK and do some clean up operations.
My script is running FINE via ESTK but is NOT executing the menu command when run from inside Illustrator via the menu File > Scripts > Other script.
Easy solution (after what I read in the above comments): Create a blank new file and then run the script from the menu - it runs fine now!

Likes

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