Skip to main content
Known Participant
May 7, 2013
Question

Initiating a script from a created menu

  • May 7, 2013
  • 2 replies
  • 1006 views

Ok,

I admit that I am a novice with JavaScript, although I have experience developing using Xcode with ObjC and lots of interapplication scripting with AppleScript.

However, I am clearly missing some very basic concepts trying to do some very simple things to script Adobe Bridge.

For instance, I have followed the tutorials and have had no problem running and customizing versions of SnpAddMenuItem.jsx and SnpCreateThumbnailInspector.jsx.

Now, let's say I put the SnpAddMenuItem.jsx in the Startup Scripts folder for Bridge CS6. (works fine and creates menu on launch.)

However, instead of displaying an alert, as in the demo:

alertCommand.onSelect = function (m)

    {

        var txt = m.text;

        // Display result as UI, as this is UI sample

        alert("'" + txt + "' was chosen menu item");

        // run javascript

        //SnpCreateThumbInspectorPanel.Main();

    }

I want to run  SnpCreateThumbnailInspector.jsx.

Do I:

  1. Call the script by referencing it's location on disk
  2. Include the CreatThumbnailInspector code as a function in the AddMenuItem script and direct function.OnSelect to run that function
  3. Or is there some other method that I am totally missing?

I have scoured the documentation and much of the sample scripts and can't seem to figure out this seemingly simple concept.

- James


This topic has been closed for replies.

2 replies

Participating Frequently
May 16, 2013

If I understand you correctly it's 2.

Stick you function in the onSelect event of the item.

Paul Riggott
Inspiring
May 7, 2013

Most of the examples are written to be executed from within ExtendScript Toolkit, the supplied IDE.

Just open the script in ExtendScript Toolkit and run it with Bridge as the target.

Known Participant
May 13, 2013

Well...

I'm trying to build a utility that will be used by multiple users, not a one-off script.

Paul Riggott
Inspiring
May 13, 2013

There should be many examples here on the forum, here is one that you can play with...

#target bridge  

if( BridgeTalk.appName == "bridge" ) { 

var menu = MenuElement.find ("myNewBridgeMenu");

if (menu == null){

var newMenu = MenuElement.create( "menu", "My Bridge Scripts", "before tools/ps", "myNewBridgeMenu" );

WhatEverYouWant = MenuElement.create( "command", "Test Script", "at the end of myNewBridgeMenu",  "BridgetestScript" );

    }

}

WhatEverYouWant.onSelect = function () {

    alert("This is my new script");

}