[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);
};

Tags: InDesign

Similar Questions

  • do not click on the menu that appears when I right-click my taskbar, such as the right click menu disappears when I move the mouse the right click menu

    PROBLEM: CONTEXT MENU DISAPPEARS WHEN YOU TRY ON THE LEFT, CLICK AN OPTION

    Hello
    I'm using Windows 7, and I could always
    go to my taskbar and right click
    Icons and active icons, bring to the top
    the list on the right click on the standard Menu.

    PROBLEM
    As soon as I moved my mouse away from
    the background of windows 7 taskbar to go a couple
    millimetres above on the left, click an option in
    I opened with my right click context Menu
    The whole Menu disappears, and it happens in
    Firefox version 29.01, other programs in Firefox,
    and others such as Skype.
    When I was running Firefox 28
    I didn't have this problem, can you help out me.
    Thank you
    Kev Borg

    PROBLEM
    MAKE ONE CLICK RIGHT MENU DISAPPEARS WHEN YOU MOVE YOUR MOUSE TO THE LEFT, CLICK ON A MENU OPTION IN THE RIGHT CLICK MENU.

    'YOU can not because WHEN YOU MOVE YOUR MOUSE TO THE MENU YOU JUST a RIGHT CLIC ON OPEN DISAPPEARS before you HAVE a CHANCE TO CLICK LEFT of YOUR CHOICE. "

    SOLUTION
    [ 1] GO TO control PANEL AND click HERE FOR the VIEW MENU
    [ 2] GO to "EASE of ACCESS CENTER" AT the TOP.
    [ 3] LEFT CLICK ON the MENU ITEM "theEASE of ACCESS CENTER.
    [ 4] AFTER YOU are a LEFT CLICK ON 'EASE of ACCESS CENTER' seems.
    [ 5] LOOK down THE LIST UNTIL YOU FIND to "MAKE THE MOUSE EASIER to USE".
    [ 5] THE UPPER SHOWS YOU HOW to CHANGE YOUR MOUSE COLORS ETC.
    [ 6] SCROLL DOWN UNTIL YOU SEE THIS TOPIC "MAKE IT EASIER to MANAGE WINDOWS".
    [ 7] UNDER this MENU, there is check.
    "ACTIVATE a WINDOW BY HOVERING over IT WITH YOUR MOUSE"

    [8] ARE OF COURSE IS NOT A CHECK MARK IN THIS BOX TO OPTION, IS THERE A CHECK IT AND APPLY AND CLICK OK TO SAVE.

    And now, you should have no more problems with your right click Menu disappears when you move your mouse over the menu left click on a menu item on a right click menu.

    SOLUTION SOLVES THE PROBLEM.

    Thank you and I hope this answer help all the other people who have had this frustrating problem.

    was soon KiwiKev

  • I disabled the toolbar > > Menu button (via a right click on a PC, Windows 7) and cannot access the toolbar to add items to the sail back in. Any ideas?

    I disabled the toolbar > > Menu button (via a right click on a PC, Windows 7) and cannot access the toolbar to add items to the sail back in. Any ideas?

    Don't see the menu bar not (File, Edit, View, history, Favorites, tools, help)?
    Turn on/off the menu bar is a new feature in version 3.6.
    (Linux and OSX see: what happened to the file, edit and view menus? )
    Windows Method 1. Press and hold the key and press the letters of the following in this exact order: V T M
    Windows method 2 Press and release the button. The Menu bar is displayed; then choose ~ ~ red: V ~ ~ iew > ~ ~ red: T ~ ~ oolbars and click on ~ ~ Red: M ~ ~ enu Bar.
    The menu bar should now be displayed permanently, unless you turn it off again using view > toolbars. Check = not displayed, NO check mark is not displayed.
    See: http://support.mozilla.com/en-US/kb/Menu+bar+is+missing

    Navigation, bar toolbar bookmarks and other toolbars under view > toolbars. By clicking on one of them will place a check mark (display) or remove the check mark (not shown).

    To display the status bar, view, and then click status bar to place a check mark (display) or remove the check mark (not shown).

    Mode full screen
    http://KB.mozillazine.org/netbooks#Full_screen

    See also:
    Back and front toolbar buttons or others are missing
    Customize controls, buttons, and Firefox toolbars

  • get palette via script items

    Is it possible to access the control palette and its sub-sub-pallets/controls within these secondary pallets via script? I'd like to get the channels of available items

    so... theres a range reading vi. Who would have thought... SOLUTION!

  • How to get the graph to print in color when added by script

    Hi all

    I'm trying to add an image to an article through dal, but it does not print in color when it is added using script. But if manually added it prints in color.

    Do I need to have any setting for this. Please let me know.

    Thank you.

    I'm not 100% sure that this will work, but you can try adding an empty bitmap in Studio to your section, make sure that it is marked as color printing. And then use script DAL CHANGELOGO function to change the bitmap that you want to print. So, indeed, you replace ADDLOGO by CHANGELOGO in DAL and create a bitmap on in the Studio.

  • 'Go to Page' in InCopy? Via script?

    Is it possible to get a "Go to Page" dialog in InCopy (see InDesign (layout > Go to Page))? Via script?

    If you already have a selector that integrated option didn't need script:

    Hug!

  • You can determine if a TextLayer is a Vertical or Horizontal via script?

    Hi all

    I did a little digging around and could not find if there was a way to determine if a TextLayer object was created with the Horizontal Type tool or the Vertical Type via script?  Also, it would be something that could be changed by program?

    Thank you!

    Calvin

    I'm not aware of any way to get directly to this attribute. You could probably deduce the State with sourceRectAtTime(), but I don't know any way to set/change.

    Dan

  • 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!

  • Modify the effect parameters when it is added via the advanced action

    Hello

    Is it possible to change a path of a fly when an effect is added via the advanced action?

    When an effect is added via right mouse click on > 'Effect apply', and then modifying a path is easy:

    edit a path1.png

    But when the same effect is added via advanced actions, so I can not understand how do...

    edit a path2.png
    What I wanted to achieve are a form this is the flight in/out on click. Sorting of a table of contents, but with instructions on how to complete the task. So far, I have:

    1. step 1 - nb shape. 1 is visible

    1.png
    2. step 2 - after clicking on "Hide" (on the screen above) 1st form flies out. Instead, I have form nb. 2 (this screen below)

    2.png

    3. When you click on 'Show' (on the screen above), form number 2 goes to hidden. On its place form 1 shoud appear, but it doesn't. I know they are there :) because when, for testing purposes, I stuck them on the left side of the screen, they were visible, but completely displaced.

    Here are two simple actions that I created:

    actions.png

    Any ideas?

    Pawel

    There is no video, it's a blog post. Sorry, seems I posted a wrong link: effects reset in Captivate 6 - Captivate blog

  • to access the components via script?

    Hi can someone tell me how to access the components via script

    pls... Thank you

    Hello

    You can access any component in the flex application based on the hierarchy of this component.

    parentApplication.CompParentOf_2.CompParentOf_1.AnyComponent;

    parentApplication.CompParentOf_2.CompParentOf_1.AnyPublicVar;

    ParentApplication is defined as the main appplication.

    You can use this script anywhere in the application.

    I hope this can help you if you are looking for it.

    Thank you.

    -

    Afonso

  • define an id scsi for a disc newly added for virtual machines via script

    Hi Experts,

    I used the script below to add disks to several virtual machines
    http://blog.mattvogt.NET/2013/03/14/PowerCLI-mass-add-hard-disks/

    But currently our requirement for change as if we must add 3 2 GB drives, the disks must the controller use SCSI (1:0) - (1:2)

    And next bunch of disks, for example, should use use SCSI (2:0) - (2:2).

    Y at - it an option to set the SCSI ID when adding new disks.
    Please let me know if there is nothing we can achieve through scripts.

    Thanks in advance.

    Kind regards
    Sourav

    Try this new version, it works for me in my test environment

    ### Get VM/Disk Count/Datastore information ### $vmname = Read-Host "VM Name to add disks to"$num_disks = Read-Host "number of disks to add"$ds = "Oracle DB Farm Datastore Group"$format = Read-Host "Disk Format (thin, thick, EagerZeroedThick)"$size = Read-Host "Disk Size (GB)"
    
    $vm = Get-VM $vmname$datastore = Get-DatastoreCluster -Name $ds
    
    ### Add $num_disks to VM1..$num_disks | %{  Write-Host "Adding disk $_ size $size GB and format $format to $($vm.Name) on datastore $datastore"
    
      if($_ -eq 1){      $hd = New-HardDisk -vm $vm -CapacityGB $size -Datastore $datastore -StorageFormat $format      $hd = Get-HardDisk -VM $vm | Where {$_.ExtensionData.Backing.UUid -eq $hd.ExtensionData.Backing.Uuid}      $ctrl = New-ScsiController -Type Paravirtual -HardDisk $hd  }  else{      $hd = New-HardDisk -vm $vm -CapacityGB $size -Datastore $datastore -StorageFormat $format -Controller $ctrl    $hd = Get-HardDisk -VM $vm | Where {$_.ExtensionData.Backing.UUid -eq $hd.ExtensionData.Backing.Uuid}  }}
    
  • 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...

  • Modes of draw adjustment via script?

    Is there a way of setting of the draw via a script?

    I can't find any info.

    What I would like is to set the mode to draw to paint indoors for a selected path via a script instead of double click on the toolbar button or press SHIFT + D twice.

    Hi here, present two objects of sample clips. Let me know if you need to 'draw' more than one inside.

    Select two objects (the mask on top) before running the script.

    #target Illustrator
    
    //  script.name = drawInsideViaClippingMask.jsx;
    //  script.description = makes a clipping mask, retaining fill/stroke, to simulate "draw inside";
    //  script.required = two paths selected, top most path is the clipping mask;
    //  script.parent = carlos canto // 8/16/11;
    //  script.elegant = false;
    
    if (app.documents.length > 0)
        {
            var idoc = app.activeDocument; // get active document;
            var sel = idoc.selection; // get selection
    
            if (sel.length==2) // continue only if 2 objects are selected
                {
                    var igroup = idoc.groupItems.add(); // add a group that will be the clipping mask group
    
                    var imask = sel[0]; // the mask is the object on top
                    var ipath = sel[1]; // the "drawn object" is at the bottom
    
                    var idup = imask.duplicate(); // duplicate the mask, to later get the fill and stroke to apply to the clipping path
    
                    ipath.move(igroup, ElementPlacement.PLACEATBEGINNING); // add both path to the group
                    imask.move (igroup, ElementPlacement.PLACEATBEGINNING);
    
                    imask.clipping = true; // make the mask the clipping path
                    igroup.clipped = true; // clip the everything in the group to the clipping mask
    
                    imask.fillColor = idup.fillColor; // add fill color, same as the dup
                    imask.stroked = true; // stroke the mask
                    imask.strokeWidth = idup.strokeWidth; // add stroke width, same as the dup
                    imask.strokeColor = idup.strokeColor; // add stroke color, seme as the dup
    
                    idup.remove(); // remove the duplicate
                }
            else // show this message if other than 2 objects are selected
                {
                    alert("Select both, the Mask and the object that needs to be 'inside'.\rThe Mask needs to be the top most object.");
                }
         }
     else
        {
            alert ("there are no open documents");
        }
    
  • Remove items from a context Menu added by an application

    I have an application installed on my Mac OS X El Capitan of synchronization of folders for a Synology NAS I have on my network.  This app has added a series of commands "copy to...". "in the menu contextual (right-click) to files and folders.  He also added a button in the finder window next to the search box that provides the same list of commands "copy to...". "If selected.  These are useless for me and background image upward with the context menu I use all the time for orders as open, open with, get info, etc.

    I asked Synology on this subject and they have no solution.  Their application must put those orders somewhere that the operating system is to make them.  Anyone know where it is and if it is possible to delete or prevent them to appear?

    I found this genre of similar issues related to standard orders of Mac it will the elements keyboard/shortcuts/service instructions and unchecking the list it.  But these commands are not displayed here.  If this seems not to be the solution.

    Any help is appreciated.

    Thank you

    Mark

    Have you tried in

     > system... Preferences > Extensions > here?

  • Adding another script worm IPCC Enterprise 4.6

    I broke the script live today so I ask before I try again.

    I have a script called CC_Main_V5. When I use Explorer to scripts, I can see the different versions of the script and say which one is the active version. I want to make a copy of the current version to begin programming of a newer version of it.

    I tried this way 1 and broke it - I opened the version active, makes a change in the script, chose save as and used the same name script (CC_Main_V5) but not checked the box that States make the active script on save. I thought that this would add another version in the script editor I could modify and play with.

    What's happened is that the active script became CC_Main_V4. It is a totally different script name, don't know why it turned on instead of a different version of the CC_Main_V5 script.

    So my question: how to make a copy of the script CC_Main_V5 which will apper in the Script Explorer when I develop the CC_Main_V5. I want to be able to switch between life and my test.

    Thank you

    When you're in the script editor and you go to edit a script, it automatically increases the 'version' one meter.

    (as indicated on the bar at the top of the page windows check this just open a script in the 'Browse' mode. then click on the "Edit" button to put the script in Ed. mode version should have a better by one of what appeared to be the version in browse mode.)

    You should see something like the following in the top bar of the window:

    IE: Script Editor [CC_Script {all customers}.013 [live Version] [Browse]]

    (this script is called CC_Script and is the version.013 and is in navigation mode)

    When you switch to edit mode, you should see something like the following:

    Script editor [CC_Script {all customers}.014 [live Version] [edit]]

    (this script is still named CC_Script and is now the version.014 and is in edit mode)

    (automatically augmented version and you need to do to keep this version is to press save button; or leave it prompts you for a backup if you were to press the browse buttons or monitor)

    When you save the script, do not use the function "save under" but comes regularly record.

    You can use ' options > Preferences on the menu drop-down menus to set the option 'automatically make a script active when recording' off. This will allow you to save the script with registration works but do not do it activates.

    enabled or not, this version of the script has now shown that the first script in the script Explorer list.

    Please visit this link on the Administration's Script more ICM 4.6:

    http://www.Cisco.com/en/us/products/SW/custcosw/ps1001/products_user_guide_chapter09186a00800f061f.html

Maybe you are looking for

  • HTML5 and youtube

    Hi, after update 10 Safari, youtube stopped opening, because she needs to HTML5. Where can I download or is - it possible to make YouTube work with FLASH? Thank you

  • Simultaneous removal iMessages

    With the help of iMessage on my iPhone 6 s, MacBook and iPad Pro, is it possible to simultaneously remove an iMessage on all devices at the same time, rather than having to individually delete each device?

  • Transfer pictures from old PC to iPad - no synchronization

    My friend has an old PC and asked me to pass his many photos of her on his iPad. I read everywhere and thought I needed to sync photos to the iPad via iTunes, I did through my Mac and an external hard drive. However, she cannot delete pictures of his

  • Software problem?

    I have a brand new Apple Watch - he got last week and have updated to the latest version of the software. The day I received the watch (as a gift) I could do what I tried to do. The next day, however, after the update to the latest version of the sof

  • Question about updated driver XP - Vista

    Is it possible to update the BIOS and drivers for windows Vista compatible even if the operating system is always Windows XP?What are the incompatibility? If there is any.