3 Replies Latest reply on Sep 21, 2011 8:39 AM by JJ0330

    Create custom menu with applescripts.

    JJ0330

      Looking to create a custom menu and add a couple applescripts that we wrote to that dropdown menu.  I found the sample applescript "MakeScriptMenuAction" but am confused on how to add our scripts to it.  For example if I had 2 scripts called GTScript1 and GTScript2 that I'd like to have run from custom menu called GT Scripts, is there a way to do this?   Thanks, Joe

        • 1. Re: Create custom menu with applescripts.
          Muppet Mark Level 5

          Where did you acquire this sample… Does Adobe supply it?

          • 2. Re: Create custom menu with applescripts.
            JJ0330 Level 1

            Yes, it came with CS5.5 in sample scripts.

            • 3. Re: Create custom menu with applescripts.
              JJ0330 Level 1

              Here is contents of script.  I'm guess it might be on the oninvoke statement but can't get either syntax of path correct or something?   My file would be in Applications folder in subfoldfer called GTScripts with script name of GTScript1.   It creates menu and menu items correctly but when click on to execute, doesn't work.

               

              set myEventListener to make event listener with properties {event type:"onInvoke", handler:"yukino:message.applescript"}

               

               

              --Original Script--

               

              --MakeScriptMenuAction.applescript
              --An InDesign CS5.5 AppleScript
              --
              --Adds a custom menu to the main menu bar.
              main()
              on main()
              mySetup()
              mySnippet()
              myTeardown()
              end main
              on mySetup()
              end mySetup
              on mySnippet()
              tell application "Adobe InDesign CS5.5"
                --<fragment>
                --Create the script menu action "Display Message" if it does not already exist.
                try
                 set myScriptMenuAction to script menu action "Display Message"
                on error
                 set myScriptMenuAction to make script menu action with properties {title:"Display Message"}
                end try
                tell myScriptMenuAction
                 --If the script menu action already existed,
                 --remove the existing event listeners.
                 if (count event listeners) > 0 then
                  tell every event listener to delete
                 end if
                 set myEventListener to make event listener with properties {event type:"onInvoke", handler:"yukino:message.applescript"}
                end tell
                tell menu "$ID/Main"
                 set mySampleScriptMenu to make submenu with properties {title:"Script Menu Action"}
                 tell mySampleScriptMenu
                  set mySampleScriptMenuItem to make menu item with properties {associated menu action:myScriptMenuAction}
                 end tell
                end tell
                --</fragment>
              end tell
              end mySnippet
              on myTeardown()
              end myTeardown