4 Replies Latest reply on Feb 24, 2015 8:20 AM by andy.kirk

    Clean up custom menu on app close in CS4




      I currently have an issue which I've been banging my head against the wall for too long and would like some expert advice. I have an ExtendScript setup to run on InDesign startup and I create a custom menu when the script is initialized. What I'm finding is, after I close InDesign and "uninstall" my script (remove from startup for instance) and re-open InDesign, my custom menu is still there! What gives?


      So, I started by scripting in CS5.5 and solved this lack of clean up by adding a beforeQuit event on the application and manually removed my custom menu. This works great, in CS5.5. I need to make this script CS4 compatible, and it appears there are no events/ways to handle when the application closes. My menu is not document specific, so I can't leverage document close events.


      So I've boiled it down to the following code snippet that represents the problem:


      #target indesign

      #targetengine "MyEngine"


      function setupMenu()


      app.menus.item('$ID/Main').submenus.add('Test Menu');





      If you put the code above in a startup script, you get the menu. If you then remove the startup script, you still get the menu. I find it hard to believe that once you create a menu item in InDesign, you can't get rid of it unless you manually remove it yourself. Am I misguided/mistaken?


      Ultimately, is there a way I can, when the application closes, remove any custom menu I created so that on next launch, if the script was removed, the menu is no longer present in CS4?


      Thanks for any help!