Skip to main content
Participant
June 15, 2005
Question

executing menu items

  • June 15, 2005
  • 10 replies
  • 695 views
Hi,

I am trying to write a script that, simply enough, tells Bridge to show Graphic Files Only, and to Show 1 or More Stars. I can get the menu elements with MenuElement.find('FilterGraphicFiles'), but cannot figure out how to act on this. Please help.

Thanks
This topic has been closed for replies.

10 replies

Known Participant
June 24, 2005
Bartram,

There was a late addition to bridge scripting that didn't make the documetnation. Instead of using Thumbnail.metadata, try using

Thumbnail.synchronousMetadata

to get a Metadata objectin scripting.

Thumbnails and Metadata objects are initialized asynchronously. This isn't an issue when browsing in bridge. But scripts execute at a speed that does not allow for that initialization time. If your script is executed while thumbnails are being initialized for a given document, the Metadata object returned might not be ready for use and might fail to read the metadata correctly. Using synchronousMetadata should avoid that possibility.

Bob
Adobe WAS Scripting
Participant
June 22, 2005

I figured it out. There is a Rating property associated with the "http://ns.adobe.com/xap/1.0/" namespace, helpful for sorting your picks from your rejects. This works like a charm:

var items = app.document.visibleThumbnails;
for (i = 0; i < items.length; i++) {
	var m = items[i].metadata;
	m.namespace = "http://ns.adobe.com/xap/1.0/";
	if (m.Rating > 0) app.document.select(items[i]);
	else app.document.deselect(items[i]);
}

Bartram

Participant
June 17, 2005
Thanks for looking into it. I've been trying to script sorting files by type and rating for so long. It always seemed kinda funny that PS didn't have a way to tell if a file had been flagged or rated using JavaScript- you can see every other piece of metadata but that. If that worked, it would make my life so much easier.

Bartram
Known Participant
June 16, 2005
Not much difference, really.

Confirmed a problem in that method. It'll get fixed, but not much we can do about it today.

Sorry.
Inspiring
June 15, 2005
What is the difference between an undocumented feature that doesn't work and a feature that doesn't exist?

Dave
Known Participant
June 15, 2005
You can always use the reflection object (which is documented). That's how I found chooseMenuItem.

app.document.reflect.methods
app.document.reflect.properties

Bob
Participant
June 15, 2005
Doesn't work for me, either, but it would be awesome if it did. Is there a way to find these undocumented features, if only so I (and others) can experiment?

Thanks
Known Participant
June 15, 2005
There is an undocumented function, chooseMenuItem( menuID ) that is a part of the Document object.

app.document.chooseMenuItem( "FilterGraphicFiles" );

should work, but doesn't for me. I'm checking on it now.

Bob
Participant
June 15, 2005
Hi Robert,

Thanks for your quick reply, but that wasn't quite my intention. I want to automatically execute the functionality of existing menu items, without the user having to select the menu item. Specifically, I want the script to "Show Graphic Files Only." Is there a way to do this in code, without the user's interaction?

I'd be happy to post the script when I get it working.

Thanks
Known Participant
June 15, 2005
Bartram,

You have to set up a handler for a menu event.

When you create your menu...

MyNamespaceObject.myMenuHandlerFunction = function( menu ) {
alert( "My Menu was selected" );
}
var myMenu = MenuElement.create( "command", "My Menu", "at the end of Tools", "Tools/MyMenu" );
myMenu.onSelect = MyNamespaceObject.myMenuHandlerFunction;

When the menu is selected by the user, your menu handler function will execute.

I'd like to see the script when you've got it ready!

Bob
Adobe WAS Scripting