Menu color by Script

Hi Experts,

I'm trying to create a Menu ID that contains submenus, and I want to apply the color for this menu. It can be done manually by Edit-> Menus...-> by selecting the menu, next to this menu, we can change the color, is to enter into the menu. But I did not have to do with Automation by using google Javascript.I a lot to achieve. But I can not find, even in this forum too. That's why I ask this question to the expert ID. And I add the menu, have submenus (view > symbol,) I can able to add colors manually. Other menu items that does not submenus, I can't able to apply colors manually too... You can guide me expert!

I tried the codes below. But I can not find the color property.

var menuName = app.menuActions.itemByID (6146);

var x = NomMenu;

Alert (x.Properties);

var y = x.properties;

Alert (y.toSource ());

Output:

error.png

Thank you and best regards,

Velprakash.

I don't think it's available via the script. Submit a feature request...

Tags: InDesign

Similar Questions

  • menu color picker

    Hi im trying to put a piece of furniture with a menu of colors, and when you click on the colors I want the legs of a table of example to change depending on the color, click. How do I do that? Please somebody guide me. Thanks in advance,

    It's complex script stuff and a lot of image editing. None of this has nothing to do with the Muse.

    Mylenium

  • Chaning color Illustrator script?

    Hello community! I have about 600 files that I need to change the colors of pale green/dark green to light blue/dark blue, and I need a script for this. Here are a few simple letters divided in two and everything I need is the upper part to be dark blue instead of dark green and the lower part to be light blue instead of the original light green. Is this possible? I use windows 10 as my operating system. Any help is very appreciated!

    Kind regards

    David.

    This code should you select a folder and then loop through all files with. EPS file extensions.
    Note that this script assumes that all colors are exactly the same two Greens as in this sample file you sent.

    You will need to replace the RGB values of the above colors in the marking lines.<- here"="" with="" the="" values="" for="" the="" new="" blue="">

    function ConvertColors() {
    
        /* REPLACE THESE RGB VALUES */
        var topColor = new RGBColor();
    
        topColor.red = 0;    // <- HERE
        topColor.green = 0;    // <- HERE
        topColor.blue = 255;   // <-HERE
    
        var bottomColor = new RGBColor();
    
        bottomColor.red = 255;   // <- HERE
        bottomColor.green = 0;   // <- HERE
        bottomColor.blue = 0;  // <- HERE
    
        /* ~~~~~~~~~~~~~~~~~~~ */
    
        // we'll just use the Red value of the top to identify which color we have
        var oldTopColor = 140;
    
        var dir = Folder.selectDialog("Where?");
        var files = dir.getFiles("*.eps");
    
        // loop through all the files in the selected directory
        for(var f = 0; f < files.length; f++){
            var doc = app.open(files[f]);
    
            // loop through all paths and change the colors based on current fill
            var paths = doc.pathItems;
            for( var i = 0, ii = paths.length; i < ii; i++ ) {
                var curPath = paths[i];
    
                // check the fill color to see if it has the same Red value as the old top color
                if( curPath.fillColor.red == oldTopColor ) {
                    curPath.fillColor = topColor;
                }
                // if not it must be the bottom color
                else {
                    curPath.fillColor = bottomColor;
                }
            }
    
            // close and save the changes
            doc.close(SaveOptions.SAVECHANGES);
        }
    }
    
    ConvertColors();
    

    I hope this helps!

  • Color conversion script?

    I am looking for a way to print the CMYK, RGB, HEX easily, in the text, and possibly another representation of certain colors, I thought I'd write a quick script... easy, right? Apparently not.

    Although I have never used, it seems that Photoshop has the 'SolidColor' object, which has properties for 'cmyk', 'rgb', 'gray' etc... exactly what I need, except I want to do that in Illustrator. Illustrator has the "CMYKColor', 'RGBColor" etc. objects with, from what I can tell, no way to convert any other color mode.

    Then. am I missing something obvious? Or y at - it no way to easily get representations of different a color in artificial intelligence object color mode? I know that the conversion will be different according to the profiles of boards etc., but the UI color picker has the right values that already and, apparently, Photoshop can do it without problem so I'm hoping that I'm missing just something obvious!

    I tried to change the "TypeName" of the Color object, I've seen suggested, but it made no difference (the docs say it is read only).

    The only other options I can think is to create a new document in color mode I want to convert, to create a new color from the existing (which from reading the reference sounds like it will be auto-convertir it in this color mode) read the values of the new color and close the newly created document. But that seems to be a horrible workaround. Or, set up my own conversion function, which seems so horrible (since I thought it would be easy to write quick script!)

    Any input would be appreciated!

    Your code has been very useful Silly-V, convertSampleColor(), it was exactly what I was looking for! If you or anyone is interested, now is my script. Havn't tried a lot and it could probably be cleaned up a bit, but it should work (it does for me with CS6 on OS X).

    It takes all your selected samples and print the CMYK, RGB and HEX (and name if it is a spot color) all these samples selected in a txt file. The txt file is saved with the same name and in the same folder as your Illustrator file. If your Illustrator file is unregistered, it records the txt file in your home directory.

    // Color Modes To Text
    // ===================
    
    // Prints CMYK values, RGB values and HEX value of all selected swatches to a .txt file
    // The .txt file is saved with the same file name and inc the same folder as the .ai file
    // If the .ai file hasn't been saved, the .txt file is saved in the users home directory
    
    main();
    function main()
    {
        var doc = app.activeDocument;
        var selectedSwatches = doc.swatches.getSelected();
    
        if (selectedSwatches.length > 0)
        {
            var text = "";
    
            for (var i = 0; i < selectedSwatches.length; i++)
            {
                var swatch = selectedSwatches[i]
                var color = swatch.color;
    
                // Spot
                if (color.typename == "SpotColor") {
                    text += color.spot.name + "\n";
                    color = color.spot.color;
                }
    
                // CMYK Source
                if (color.typename == "CMYKColor")
                {
                    // CMYK Values
                    text += "C=" + Math.round(color.cyan) + " M=" + Math.round(color.magenta) + " Y=" + Math.round(color.yellow) + " K=" + Math.round(color.black) + "\n";
    
                    // RGB Values
                    var rgb = convertColor("CMYK", "RGB", [Math.round(color.cyan), Math.round(color.magenta), Math.round(color.yellow), Math.round(color.black)]);
                    text += "R=" + Math.floor(rgb[0]) + " G=" + Math.floor(rgb[1]) + " B=" + Math.floor(rgb[2]) + "\n";
    
                    // HEX Values
                    text += rgbToHex(Math.floor(rgb[0]), Math.floor(rgb[1]), Math.floor(rgb[2])) + "\n";
                    text += "\n";
                }
                // RGB Source
                else if (color.typename == "RGBColor")
                {
                    // CMYK Values
                    var cmyk = convertColor("RGB", "CMYK", [Math.round(color.red), Math.round(color.green), Math.round(color.blue)]);
                    text += "C=" + Math.round(cmyk[0]) + " M=" + Math.round(cmyk[1]) + " Y=" + Math.round(cmyk[2]) + " K=" + Math.round(cmyk[3]) + "\n";
    
                    // RGB Values
                    text += "R=" + Math.floor(color.red) + " G=" + Math.floor(color.green) + " B=" + Math.floor(color.blue) + "\n";
    
                    // HEX Values
                    text += rgbToHex(Math.floor(color.red), Math.floor(color.green), Math.floor(color.blue)) + "\n";
                    text += "\n";
                }
            }
            saveTxt(text);
        }
        else {
            alert("No Swatches Selected.");
        }
    }
    
    function convertColor(src, dest, clrArr)
    {
        return app.convertSampleColor(ImageColorSpace[src], clrArr, ImageColorSpace[dest], ColorConvertPurpose.defaultpurpose);
    }
    
    function componentToHex(c)
    {
        var hex = c.toString(16);
        return hex.length == 1 ? "0" + hex : hex;
    }
    
    function rgbToHex(r, g, b)
    {
        return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
    }
    
    function saveTxt(txt)
    {
        var name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
        var path = (app.activeDocument.path != "") ? app.activeDocument.path : "~";
    
        var saveFile = new File(path + "/" + name + ".txt");
    
        if(saveFile.exists)
            saveFile.remove();
    
        saveFile.encoding = "UTF8";
        saveFile.open("e", "TEXT");
        saveFile.writeln(txt);
        saveFile.close();
    
        alert("Saved to File:\n" + saveFile.fullName)
    }
    
  • How to remove colors custom Script UI control?

    Dear forum,

    I am writing a script for batch renaming links in InDesign.

    1.jpg

    If the user types the text edit field the new name which coincides with name of the original link (1st static text in the Group), the script gives a warning and he painted red.

    2.jpg

    3.jpg

    When the user solves the problem by making the new different name, the script he painted black.

    15-11-2015 20-30-37.jpg

    Here's where I got so far:

    g.et.onChange = function() {
        if (this.parent.children[0].text.replace(/\.[^\.]+$/, '') == this.text) {
            alert("\"" + this.text + "\" - the new name is the same as the old one! The file won't be renamed.", "Error", true);
            this.graphics.foregroundColor = this.graphics.newPen(this.graphics.PenType.SOLID_COLOR, [1, 0, 0], 1);
        }
        else {
            if (this.graphics.foregroundColor != undefined) {
                $.writeln("Names are different: change the name from red to black.");                        
                this.graphics.foregroundColor = this.graphics.newPen(this.graphics.PenType.SOLID_COLOR, [0, 0, 0], 1);
            }
        }
    }
    

    "g" is the text in a group.

    I wonder, is there a way to reset the color to the default text instead of repainting it?

    Currently, it checks if foregroundColor of graph is not undefined - which is painted with "newPen" - and if it is true, he painted black. But I guess it is a clumsy workaround and there should be a good way to do this.

    Kind regards

    Kasyan

    Hi Kasyan

    Pre CC could set the color to null, CC, this causes an accident.

    PS there are other options (color theme), but not on ID so paint is the only option I know.

    The challenge is dealing with default colors that depend on the setting. To change the text in the foreground is always black background colors you can either take the approach here Re: Re: Re: Re: ScriptUI: element of change to the default color

    Or a longer but more effective approach would be to go pass 100 values possible topic and get the associated rgb values.

    Probably not interesting put in a lot of effort as the way things are going THAT SUI will not support editing text in a few years.

    Concerning

    Trevor

  • Change the Menu colors:

    Copy-Paste.png

    Above: When I 'Copy' and 'Paste' an image (RGB .jpg) in Illustrator CS5 I get some options in the Edit Menu of colors.

    Below: When I have 'place' of the same image is what I get:

    Place.png

    Is there a setting somewhere is going to fix this? I dropped the preferences and the com.adobe.illustrator.plist

    Thank you.

    Bob,

    Integrate the image, you placed a linked file.

  • Export of the correct Hex colors via script

    Hi all

    I need to export the fillColor of a paragraph via script style.

    I can get the fillColor of the paragraph style property and can also convert CMYK Hex. However, I realize that color in InDesign values in some color space of the document uses.

    My question is, is there a native API to convert the values of color for a web safe color value? If this is not the case, how can I go on the correspondences between colors?

    In addition, I see that Adobe knows internally to convert it to a good hex color (attached screenshot - note the color property in the export marking side). If I can't use some native API, is there a way to access the text in this pane?

    Screen Shot 2014-12-15 at 7.25.20 PM.png

    Thank you all in advance!

    Win! It worked!

    Here is the complete solution-

    Assuming that the original color is stored in a variable named color :

    var color = passedInColor; //the original color that we wish to convert.
    
    // Create a temporary color instance that we'll use to extract updated colorValues.
    var scratchColor = workingDoc.colors.add({
                             model: color.model,
                             space: color.space,
                             colorValue: color.colorValue
                        });
    
    // Now, we force adobe's internal color conversion mechanism to trigger by changing the scratchColor's color space.
    scratchColor.space = ColorSpace.RGB;
    var updatedValues = scratchColor.colorValue; // Updated values now has the properly mapped and converted RGB values.
    // You may need to round off the R, G and B values in the updatedValues array.
    // And that's it!
    

    Why am I not surprised that she should be a hacky autour work? * sigh *. It was so so so frustrating to work on this platform! I hope adobe gets his act together!

  • Model by unwanted color change script

    I defined a model I intend using as a filling. After that I selected scripted brick and model of the pop box filling up I noticed that it is by changing the colors of my boss. I put the cursor of random color to 0 but the colors of my original pattern are different.

    I don't want my pattern color to change. Is this possible?

    I thought about it.

    If your color RGB mode the colors remain the same. Is it your CMYK color mode as it was for me, the colors change.

    You must change it back between RGB and CMYK

  • The menu color

    My page has master has a menu and it is one color other than gray, which is the generic color starts on. But on every page that is on the menu, when its on this page, the color is gray on the square marked this page. So as on the words we page, when it is on this page, he has this place that grey, not brown. See the photo below. I don't know how to solve this problem. Any help you could give me would be amazing.

    Screen Shot 2013-03-09 at 10.22.17 AM.png

    It is the active State for the Menu item.

    Thank you

    Vinayak

  • How to change the menu colors when you use the menu widget?

    So I inserted a menu using the menu widget, but how can I change the background colors? at this time is grey

    To change the background color of the item of a menu, simply select the Menu item (by clicking on the Menu twice) and change the color using the options of filling for the different States. If you change selection set in the options list, the color would be changed for all menu items.

    Thank you

    Vinayak

  • color fusion scripts

    I need to change the RGB values (imported from the word) of specific CMYK values in Indesign (this isn't a straight swop) so I need a script or a similar plug-in that allows me the contribution of color to CMYK values, so they change automatically... the doc I work on is huge and im importing from a file word several times so I need to save time!

    Can someone help me?

    Thank you!

    Hi baby.

    Please try the JS code below.

    var myIDOc = app.activeDocument;
    var mySwatch = myIDOc.swatches;
    for (j=mySwatch.length-1; j>=0; j--){
        try{
             if(mySwatch[j].space ==ColorSpace.RGB){
                 if(mySwatch[j].name=="Word_R122_G75_B153"){
                    mySwatch[j].remove("C=48 M=72 Y=0 K=0");
                    }
                else if(mySwatch[j].name=="Word_R255_G0_B255"){
                    mySwatch[j].remove("C=0 M=100 Y=0 K=0");
                    }
                else if(mySwatch[j].name=="Word_R0_G0_B255"){
                    mySwatch[j].remove("C=100 M=0 Y=0 K=0");
                    }
                else if(mySwatch[j].name=="Word_R0_G0_B0"){
                    mySwatch[j].remove("Black");
                    }
                else if(mySwatch[j].name=="Word_R234_G229_B255"){
                    mySwatch[j].remove("C=8 M=10 Y=0 K=0");
                    }
                 }
             }catch(e){}
         }
    

    THX,

    csm_phil

  • [JS] Menu added via script moves

    I was able to sucessfully add items at the mercy of the InDesign menu partly to Marijan Tompa (tomaxxi) blog post http://indisnip.wordpress.com/2010/08/08/create-customized-menu/

    My test (below) code creates a new menu and sucessfully adds two menu items and a submenu. The submenu causes me problems. When you first launch InDesign, it is created in its place (in the middle of the menu). But when you restart InDesign, the submenu will move to the top of the menu and never goes back to its good position further down in the menu where it was the first time that InDesign was launched.

    I searched up and down in this forum, the web and the InDesign documents and cannot find a way to stop it from moving (I want the menu to be further down the menu, not on top). I hope one of you kind souls will help me control the position of the submenu (and have it stay across launches).

    Thanks in advance!

    Dan

    Here's the code I'm working with. This is recorded as testMenu.jsx in the Scripts > startup scripts folder.

    P.S. I'm trying this in CS5.5 currently, but ideally, this solution should work in CS3 and later.

    #targetengine "myTestMenu"
    
    
    var myFolder = Folder(app.activeScript.path);
    myFolder = myFolder.parent + '/Scripts Panel/';
    
    
    var menuItem1Handler = function( /*onInvoke*/ ){
      app.doScript(File(myFolder + 'MyTest1.jsx'));
    };
    
    
    var menuItem2Handler = function( /*onInvoke*/ ){
      app.doScript(File(myFolder + 'MyTest2.jsx'));
    };
    
    
    menuInstaller()
    function menuInstaller() {
      var menuItem1T = "My Menu Item 1",
           menuItem2T = "My Menu Item 2",
           menuT = "MyTestMenu",
                 subT = "Sub Menu",
           subs = app.menus.item("$ID/Main").submenus, sma, mnu;
      var refItem = app.menus.item("$ID/Main").submenus.item("$ID/&Layout");
    
    
      subMenu1 = app.scriptMenuActions.item(menuItem1T);
      if( subMenu1 == null ) {
              subMenu2 = app.scriptMenuActions.add(menuItem1T);
      }
    
    
      subMenu2 = app.scriptMenuActions.item(menuItem2T);
      if( subMenu2 == null ) {
              subMenu2 = app.scriptMenuActions.add(menuItem2T);
      }
      subMenu2.eventListeners.add("onInvoke", menuItem2Handler);
    
    
      mnu = subs.item(menuT);
      if( mnu == null ) {
                mnu = subs.add(menuT, LocationOptions.after, refItem);
      }
      mnu.menuItems.add(subMenu1);
      mnu.menuSeparators.add();
    
    
      subsSubs = app.menus.item( '$ID/Main' ).submenus.item( menuT ).submenus;
      mnuSubMenu = subsSubs.item( subT );
      if( mnuSubMenu == null ) {
              mnuSubMenu = subsSubs.add( subT);
      }
    
    
      mnu.menuItems.add(subMenu2);
    };
    
    

    Thank you all very much for your answers and thank you substances making it finally work!

    Just to ensure that it can serve as one resource for others in the future, below is a menu (work) final based on the code of Harb. I also added 2 submenu items just to be complete.

    Thanks again to all. I'm so happy that you could help to get this working!

    Dan

    #targetengine "HarbsTestMenu"
    
    menuInstaller();
    
     function menuInstaller() {
        // SET THE FILES THAT ARE TRIGGERED BY MENU ITEMS
        menuItem1Handler = function( /*onInvoke*/ ){
            app.doScript( File(myFolder + 'File-One.jsx') );
        };
        menuItem2Handler = function( /*onInvoke*/ ){
            app.doScript( File(myFolder + 'File-Two.jsx') );
        };
        subMenuItem1Handler = function( /*onInvoke*/ ){
            app.doScript( File(myFolder + 'File-Three.jsx') );
        };
        subMenuItem2Handler = function( /*onInvoke*/ ){
            app.doScript( File(myFolder + 'File-Four.jsx') );
        };  
    
        // SET GENERAL VARIABLES
        try {
            myFolder = app.activeScript;
        }
        catch(e) {
            myFolder = File(e.fileName);  // we are running from the ESTK
        }
        myFolder = myFolder.parent.parent  + '/' ;  //this file is in the "startup scripts" subfolder
    
        var menuItem1T = "My Menu Item 1",
           menuItem2T = "My Menu Item 2",
           subMenuItem1T = "My SubMenu Item 1",
           subMenuItem2T = "My SubMenu Item 2",
           menuT = "HarbsTestMenu",
           subT = "Sub Menu",
           subs = app.menus.item("$ID/Main").submenus, mnu;
        var refItem = app.menus.item("$ID/Main").submenus.item("$ID/&Layout");
    
        // CREATE MENU ITEMS
        subMenu1 = app.scriptMenuActions.item(menuItem1T);
        if( subMenu1 == null ) {
            subMenu1 = app.scriptMenuActions.add(menuItem1T);
        }
        subMenu1.eventListeners.add("onInvoke", menuItem1Handler);
    
        subMenu2 = app.scriptMenuActions.item(menuItem2T);
        if( subMenu2 == null ) {
            subMenu2 = app.scriptMenuActions.add(menuItem2T);
        }
        subMenu2.eventListeners.add("onInvoke", menuItem2Handler);
    
        subSubMenu1 = app.scriptMenuActions.item(subMenuItem1T);
        if( subSubMenu1 == null ) {
            subSubMenu1 = app.scriptMenuActions.add(subMenuItem1T);
        }
        subSubMenu1.eventListeners.add("onInvoke", subMenuItem1Handler);
    
        subSubMenu2 = app.scriptMenuActions.item(subMenuItem2T);
        if( subSubMenu2 == null ) {
            subSubMenu2 = app.scriptMenuActions.add(subMenuItem2T);
        }
        subSubMenu2.eventListeners.add("onInvoke", subMenuItem2Handler);
    
        mnu = subs.item(menuT);
        if( mnu == null ) {
            mnu = subs.add(menuT, LocationOptions.after, refItem);
        }
    
        subsSubs = app.menus.item( '$ID/Main' ).submenus.item( menuT ).submenus;
        mnuSubMenu = subsSubs.item( subT );
        if( mnuSubMenu == null ) {
            mnuSubMenu = subsSubs.add( subT);
        }
        mnu.menuItems.add(subMenu1,LocationOptions.BEFORE,mnuSubMenu);
        mnu.menuSeparators.add(LocationOptions.BEFORE,mnuSubMenu);
        mnu.menuItems.add(subMenu2,LocationOptions.AFTER,mnuSubMenu);
        mnuSubMenu.menuItems.add(subSubMenu1,LocationOptions.AFTER,mnuSubMenu);
        mnuSubMenu.menuItems.add(subSubMenu2,LocationOptions.AFTER,mnuSubMenu);
    };
    
  • Color select Script needs refining

    Hello

    I've been running this simple script (created by an end PS scripter) in action:

    #target Photoshop

    main() {} function

    if(!documents.) Length) return;

    app.activeDocument.colorSamplers.removeAll ();

    var X = activeDocument.width.as('px')/2;

    var sample = activeDocument.colorSamplers.add ([new UnitValue (X, 'px'), new UnitValue (1, 'px')]);

    app.backgroundColor = sample.color;

    app.activeDocument.colorSamplers.removeAll ();

    }

    main();

    It selects the top center pixel color, sample, for the bottom point. Now I need to select a 5 x 5 moy. Second, is there a way to hide the INFORMATION pane, which opens by running the script? This appears not be called from an action, of course, and I'm not script.

    Thanks for any help.

    This should make an average...

    #target Photoshop
    function main(){
    if(!documents.length) return;
    var startRulerUnits = app.preferences.rulerUnits;
    app.preferences.rulerUnits = Units.PIXELS;
    try{
    app.activeDocument.colorSamplers.removeAll();
    var X = activeDocument.width/2;
    var LB=[];
    LB[0] = X.value;
    LB[1] = 1;
    LB[2] = X.value +5;
    LB[3] = 6;
    var tmpColour = new SolidColor();
    var savedState = activeDocument.activeHistoryState;
    activeDocument.selection.select([[LB[0],LB[1]], [LB[2],LB[1]], [LB[2],LB[3]], [LB[0], LB[3]]], SelectionType.REPLACE, 0, false);
    activeDocument.activeLayer.applyAverage();
    var sample = activeDocument.colorSamplers.add( [ new UnitValue( X+1, 'px' ), new UnitValue( 2, 'px' ) ] );
    tmpColour=sample.color;
    activeDocument.activeHistoryState = savedState;
    app.backgroundColor=tmpColour;
    app.preferences.rulerUnits = startRulerUnits;
    }catch(e){alert(e + " - " + e.line);}
    }
    main();
    

    I was not able to stop the information panel so I add to my open panels is not intrusive.

  • Is there something like the Palette Actions Insert menu Item for Scripts?

    The Action Palette has a feature that allow you to insert steps in shares that cannot be saved.  This means that the ScriptListener has no can be used to generate the code of script for the following steps to use the action handler interface.  Is there anything by making Action and using doaction(name,set) in a script to extract the action step in a script.  I have a script which should not depend on a given action, the value being loaded.

    Xbytor is a script in his xtools that converts javascript (Stock Manager) actions. You can use it to access the code created by the menu imsert element.

    Or if you will list the menuItems you want script X or I should be able to view the code for you. We libs of function and we have already converted most of the useful menuItems.

  • Access to the project color management script

    I know that you can access some color management settings in a script (i.e. bitsPerChannel), but I don't know about the others. In particular, can you get/set the workspace through a script? Thank you.

    N ° no color management controls are available in a script. bitsPerChannel and linearBlending are parameters of project that are associated with the color, but none are specific to color management.

    If you want to access the color management settings through scripts, please file a feature request.

Maybe you are looking for