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.
var doc = app.activeDocument;
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'.
it works ok here. Windows 10, CC2017
Did you try restarting your Illustrator and not revealing the document color space menu item and running the test?
that's correct, I tried a couple times on a newly restarted illustrator session.
Well, maybe it's just a Mac thing.
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)
lost the bet...still works fine.
I'm running your test() from the estk
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.
you're a mad man, let me try 3 more times
This is but my file, which I made just now and it's defying me even as we speak!
By the way, I'm on 21.0.1 and this is definitely happening on Macs. My OS is El Captain.
...still worked fine everytime
Ha I shall try on Windows in the morning. Maybe it's why it's gone unnoticed for a while now.
Your code completely works fine in my El Captan.
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.
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)
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)
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.
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
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?
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?
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.
is this issue solved，I am in Illustrator 2021 and this issue happen in Mac with M1，but OK in Win10
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!