What is the simplest way to invoke the command associated with an existing menu item from a plugin?

Hey there,
My specific task is to bring forward the "Swatches" window.  I want to initiate this from my plugin code (C++).  However, I may want to execute other menu items in the future, so understanding the simplest, most straightforward general mechanism would be great.
I've pieced together a sequence that could work using the Menu and Interface suites, but it seems more complicated than it should be and requires knowledge of the localized name of the menu item (incomplete and uncompiled sample code below).  Is there a better way to do this?
// Get the menu item handle by walking all items to find the swatches item
long numMenuItems = 0;
sAIMenu->CountMenuItems( &numMenuItems );
AIMenuItemHandle menuItemHandle;
ai::UnicodeString localizedItemName;
for ( long menuItemIndex = 0; menuItemIndex < numMenuItems; ++menuItemIndex )
    sAIMenu->GetNthMenuItem( menuItemIndex, &menuItemHandle );
    sAIMenu->GetItemText( menuItemHandle, localizedItemName );
    if ( localizedItemName == “Swatches” )
        break;
AIBoolean bchecked =false;
sAIMenu->IsItemChecked( menuItemHandle,
                        &bchecked );
if ( !bchecked )
   // Find the plugin responsible for adding and responding to the menu item
    SPPluginRef swatchPlugin;
    sAIMenu->GetMenuItemPlugin( menuItemHandle, &swatchPlugin );
   // Construct and send a message to the plugin instructing it to execute as if the menu item were invoke by the user
    AIMenuMessage message;
    sSPInterface->SetupMessageData( swatchPlugin, &message.d );
    message.menuItem = menuItemHandle;
    SPErr result;
    sSPInterface->SendMessage( swatchPlugin, kAIMenuCaller, kSelectorAIGoMenuItem, &message, &result );
    sSPInterface->EmptyMessageData( swatchPlugin, &message.d );
Glen.

That's a clever solution to a problem I'd never considered (but can see how others might need it) I can't think of a better way to invoke it though than what you're doing except maybe with some minor improvements. If you know the menu group, you can use AIMenuSuite::GetMenuGroupRange() to jump to that group in the overall list. Also, since menuitems seem extremely unlikely to change, you can probably cache the handle.
Beyond that, the usual suggestion I'd make it is to at least explore actions. Try recording an action and see if it even picks up when you display the Swatches panel. I'm guessing it doesn't record stuff like that, but who knows?

Similar Messages

  • What's the simplest way to edit the audio on a DVD using a Mac?

    I appreciate you taking the time to read/respond to this post.
    Here's the deal:
    My church records its service on DVDs to pass out to members.  This past weekend an annoying, high-pitch hum found it's way on to our DVD.  We also record audio versions of our service to pass out on CDs, and (scratching my head) this week's CD turned out just fine, no hum.
    Is there an easy way to detach the "bad" audio from the DVD and replace it with the good "audio" from the CD?  I know I could do what I want using iMovie, but every time I do something like this using that program, the picture quality on my new DVD looks worst than the original, plus it takes a ton of time converting and reauthoring.
    Your help and suggestions are most appreciated.

    I've never really used IMovie cause I have Final Cut, but I'm surprised its degrading your video , This makes me wonder what format your movies are in , are they .dv ( digital video ) ?
    You may even take a look at your burn settings in IDVD , I cant think of anything else outside of video editing software that will do what you are trying to do, in short its your only real option..  

  • What is the simplest way to invoke an ODI scenario from a webpage?

    Hi folks
    I have a requirement where I want number of people to be able to run certain ODI scenarios when they wish.
    Now I don't wish to roll out ODI Operator to these users.
    I'd like to create a simple web page, with a few links/buttons that will run ODI scenarios.
    Now I understand I can set up a Web application server (eg Weblogic), deploy Axis2 to this and invoke scenarios as web services etc. But this is prohibitively expensive from a licensing point of view. (And open source app server is not an option).
    I do have an apache server where I can host a simple web page. Is there a way I can get this to invoke scenarios? Or some other simple way I haven't considered?
    Thanks for looking

    ODI Web Services. You can broadcast your scenarios as web services. Here are some good reading.
    http://www.rittmanmead.com/2008/02/delving-in-to-odis-web-services-support/
    http://blogs.oracle.com/dataintegration/entry/best_practices_building_data_services_with_odi-ee
    http://john-goodwin.blogspot.com/2009/04/odi-series-web-services.html
    http://john-goodwin.blogspot.com/2009/04/odi-series-web-services-part-2.html
    http://john-goodwin.blogspot.com/2009/05/odi-series-web-services-part-3.html
    http://john-goodwin.blogspot.com/2009/05/odi-series-web-services-part-4.html

  • What is the simplest way to change the name of your home directory?

    I am not ashamed to say that I am not the least bit intelligent when it comes to macs. I came from PC, I'm learning, here. But I need to change the name of my Home directory and everything I've found online so far has either not worked (double clicking, or clicking twice but not quite double-clicking... um...okay), or described using the root user, which sounds sort of terrifying. Is there an easier way, or should I try to go by some detailed intructions and go for it?

    kurrykurry wrote:
    ... Is there an easier way,
    Yes.
    Apple Support Communities contributor Pondini found an astonishingly simple way to accomplish what you seek. etresoft distilled that information into the following User Tip:
    Changing user account short name
    It is a far better method than Apple's support article on the subject, which I will not bother linking here because it's outdated and cumbersome.

  • What is the simplest way to toggle the counter terminal when time has elapsed in the Complete PWM Example?

    I have successfully downloaded and executed this: http://www.ni.com/white-paper/2991/en
    and I know it works because I can see the pulse train on channel #1 on my osciloscope. 
    I have modified the sample code from the website to use pulse width and frequency knobs that may change dynamically:
    What I would like to do is toggle the "Dev1/ctr1" to "Dev1/ctr0" every 10 seconds.  I have investigated into the "Elapsed Time" express vi and I am able to successfully count the number of times the time has elapsed, however when 10 seconds have gone by I cannot simply update toggle input to "CO Pulse Freq" with a different counter input because it has already past that object and is busy running in the loop above.  How can I reset the pulse to execute with a different counter input?
    In short, the Elapsed Time express VI works perfectly by itself, but when the time has elapsed how do I force restarting the pulse train with "Dev1/ctr0"?
    Solved!
    Go to Solution.

    assuming you want to toggle control from 1 to 0 and back every ten secs and zeroing out the other channel...index the array to write values to one or the other channel.
    Spoiler (Highlight to read)
    note: if needed...use shift registers to hold onto the last freq/pulse width values for the last channel when toggling to the other. use 'n channel' for multiple counters, concatenate multiple channels on your counter constant
    Spoiler (Highlight to read)
    Attachments:
    toggle.vi ‏47 KB

  • What is the simplest way to get video from mini DV tapes into computer

    My computer has no firewire connection. What is the simplest way to get the video from my camera (JVC GR-D340EK) ?

    Mikeathome
    Thanks for the reply.
    The reason that I asked if this was a one time thing or not was related to my thoughts about asking you to look at the relative costs of have the DV data capture firewire done professional or by a friend versus going through looking for slots on your computer for a firewire card or purchasing a computer that still comes with a firewire port.
    We will be watching for further developments.
    Thanks.
    ATR

  • I want to load movies in to my iPad through itune in my pc that runs window XP. First of all I am not able to add the movies to the itune ,leave aside sync to iPad .can some one suggest what is the simplest way to load movies in my iPad.

    I have plenty of DVD which I load in my laptop and watch the movies while travel, however I am not able to do that in my iPad .
    I would appreciate some one guide me the simplest way of loading the movies in to my iPad. I tried the conventional procedure of loading/copying in to itune then sync to the iPad to load all movies in it, but failed to do the first step( not able to load /copy in itune) leave aside the sync to iPad next.
    Do I need to sellout some 20 odd $ to buy a conversion software that would help?
    Is it that Apple trying to make money by not making this simplest of thing possible by the user.( ref. windows, every thing is possible with little IQ of the user).
    If it is so , I would stop many of my friends to restrain from buying a device like this by spending some 1000$   ,rather look at a good Droid that is catching up so well.

    If you are the only user on your computer you probably don't have multiple user accounts set up and can disregard that.  If you are using iTunes 11 go to View>Show Sidebar.  Now see if your iPad appears under Devices on the left side when you connect it.  If it does, click on the name of your iPad on the left side and your iTunes sync settings options will appear in folders with tabbed headings to the right.
    If it doesn't appear on the left side, follow the troubleshooting steps shown in this article: http://support.apple.com/kb/TS1538.

  • Password encrypt - looking for the simplest way

    I�m implementing a web application which needs to encrypt the user password and store it in a database... (the classic scenario).
    what is the simplest way to encrypt the user password?
    I need only the encryption method..

    There are several ways: You do a secure hash of the password and store that. Then, when you want to verify the password, you do the same hash of the proposed password and if they match, you call it macaroni. Alternately, you can encrypt the password using DES or some other private key encryption technique. The technique for authentication is the same: encrypt the proposed password and if the cipertext matches that stored in your DB, the user is authenticated.
    You can do an SHA-1 hash or DES encryption using the JCE.
    See here:
    http://www.ja.net/CERT/Belgers/UNIX-password-security.html
    http://www.itworld.com/nl/unix_sec/12062001/

  • Simplest way to disassemble the multiple xml records to single xml record?

    Guys,
    I just want to know the what can be the simplest way to disassemble the input xml file into single records.
    Can we use built in XML disassemble component in custom pipeline to disassemble? If yes, how can we do it.
    Or what is other way to do it.

    Why you don't want to use Envelop Schema? Is there any specific reason for that?
    Creating envelope schema won't be a tough task you just need to make Envelop property of Schema to Yes and set Body Xpath to the container record for the child records you wish to process individually.
    Also you will have to create schema representing your child xml structure.
    Refer
    this article, it gives step by step description of the same.
    Also, as John suggested you don't even have to create a custom pipeline as the debatching can be done using default XML Receive pipeline itself.
    Let us know if you have any further question.
    Thanks,
    Prashant
    Please mark this post accordingly if it answers your query or is helpful.

  • What is the simplest  way to get a xml-file from 10g R2 -database ?

    Hi,
    I'm new in xml, there are so many tools to work with xml:
    what is the simplest way to get a xml-file from 10g R2 -database ?
    I have : 10g R2 and a xsd.file to describe the xml-structure
    thank you
    Norbert

    There is no automatic way to generate XML documents from an arbitary set of relational tables using the information contained in an XML Schema. Typically the easiest way to generate XML from relational data is to use the SQL/XML operators (XMLElement, XMLAGG, XMLAttribtues, XMLForest). There are many examples of using these operators in the forums You can validate the generated XML against the XML Schema by registering the XML Schema with XML DB and then using the XMLType.SchemaValidate() method

  • What is the simplest way to make a movie from BufferedImages?

    I have a 3d rendered animation from which I can grab BufferedImages of each frame. What is the simplest way I can create a movie from these images?
    I've seen the JpegImagesToMovie.java file and not only is it suprisingly overcomplicated, it requires me to change the code so that I can get images from memory rather than from files.
    Is there some simple way of creating a movie which requires a few statements? I'm also prepared to use QuickTime for Java. I don't care about the format, since I can just use any video converter to convert it to my desired video format.

    I recently came up with a simplified JpegImagesToMovie program. It generates QuickTime movies with a single video track output as a file. Input is a series of jpegs (currently as a list of file names, but easily modified to a take any form of jpeg data.) Since the compression used by the movie is JPEG, if you have an uncompressed image buffer, you'll need to convert that into jpeg data bytes with some quality setting. (Since its a movie file, go with something low if you have a lot of similar images.) This will even run without a full install of jmf--no native code is called (as far as I could tell..)
    Here is the source code, sorry about the formatting!
    import java.awt.Dimension;
    import java.io.File;
    import java.io.IOException;
    import java.io.RandomAccessFile;
    import java.net.URL;
    import java.util.Vector;
    import javax.media.Buffer;
    import javax.media.Format;
    import javax.media.MediaLocator;
    import javax.media.format.VideoFormat;
    import javax.media.protocol.ContentDescriptor;
    import javax.media.protocol.FileTypeDescriptor;
    import com.sun.media.multiplexer.video.QuicktimeMux;
    * This program takes a list of JPEG image files and converts them into a
    * QuickTime movie.
    * This was based on Sun's JMF Sample Code JpegImagesToMovie.java 1.3 01/03/13
    * This code is an attempt to reduce the complexity to demonstrate a very basic
    * JPEG file list to movie generator. It does not use a Manager or Processor
    * class, so it doesn't need to implement any event listening classes. One
    * advantage of this simplified class is that you can just link it with the
    * jvm.jar file. (you might also need to track down the com.ms.security library
    * stubs, use google. You'll need PermissionID.java and PolicyEngine.java.)
    * I tried to get it to generate AVI files without success.
    * These output files are could use further compression.
    * A Vector of jpeg image paths was one way to do this--the appropriate
    * methods can be overwritten to grab images from another source
    * --zip file, http, etc.
    * - Brad Lowe; Custom7; NuSpectra; 2/10/2005
    * The existing Copyright from Sun follows.
    * Copyright (c) 1999-2001 Sun Microsystems, Inc. All Rights Reserved.
    * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
    * modify and redistribute this software in source and binary code form,
    * provided that i) this copyright notice and license appear on all copies of
    * the software; and ii) Licensee does not utilize the software in a manner
    * which is disparaging to Sun.
    * This software is provided "AS IS," without a warranty of any kind. ALL
    * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
    * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
    * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
    * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
    * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
    * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
    * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
    * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
    * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY
    * OF SUCH DAMAGES.
    * This software is not designed or intended for use in on-line control of
    * aircraft, air traffic, aircraft navigation or aircraft communications; or in
    * the design, construction, operation or maintenance of any nuclear facility.
    * Licensee represents and warrants that it will not use or redistribute the
    * Software for such purposes.
    public class SimpleMovie
    Vector images; // jpeg image file path list
    VideoFormat format; // format of movie to be created..
    // Sample code.
    public static void main(String args[])
    try
    // change imageDir to the location of a directory
    // of images to convert to a movie;
    String imageDir = "images";
    File d = new File(imageDir);
    SimpleMovie imageToMovie = new SimpleMovie();
    // change width, height, and framerate!
    // Excercise: Read width and height of first image and use that.
    imageToMovie.init(320, 240, 10.0f);
    imageToMovie.setFiles(d);
    File dest = new File("simple.mov");
    imageToMovie.createMovie(dest);
    System.err.println("Created movie " + dest.getAbsolutePath() + " "
    + dest.length() + " bytes.");
    } catch (Exception e)
    System.out.println(e.toString());
    e.printStackTrace();
    // return jpeg image bytes of image zIndex (zero-based index)
    public byte[] getImageBytes(int zIndex) throws IOException
    if (images == null)
    return null;
    if (zIndex >= images.size())
    return null;
    String imageFile = (String) images.elementAt(zIndex);
    // Open a random access file for the next image.
    RandomAccessFile raFile = new RandomAccessFile(imageFile, "r");
    byte data[] = new byte[(int) raFile.length()];
    raFile.readFully(data);
    raFile.close();
    return data;
    // Call this before converting a movie;
    // Use movie width, height;
    public void init(int width, int height, float frameRate)
    format = new VideoFormat(VideoFormat.JPEG,
    new Dimension(width, height), Format.NOT_SPECIFIED,
    Format.byteArray, frameRate);
    // Set up the files to process
    public void setFiles(Vector inFiles)
    images = inFiles;
    // point converter to jpeg directory. Only does one level,
    // but could recurse, but then sorting would be interesting..
    public void setFiles(File dir) throws Exception
    if (dir.isDirectory())
    if (images == null)
    images = new Vector();
    String l[] = dir.list();
    for (int x = 0; x < l.length; x++)
    if (l[x].toLowerCase().endsWith(".jpg"))
    File f = new File(dir, l[x]);
    images.addElement(f.getAbsolutePath());
    // Crank out the movie file.
    public void createMovie(File out) throws Exception
    if (format == null)
    throw new Exception("Call init() first.");
    String name = out.getAbsolutePath();
    QuicktimeMux mux = null; // AVI not working, otherwise would use
    // BasicMux
    if (out.getPath().endsWith(".mov"))
    mux = new QuicktimeMux();
    mux.setContentDescriptor(new ContentDescriptor(
    FileTypeDescriptor.QUICKTIME));
    } else
    throw new Exception(
    "bad movie file extension. Only .mov supported.");
    // create dest file media locator.
    // This sample assumes writing a QT movie to a file.
    MediaLocator ml = new MediaLocator(new URL("file:"
    + out.getAbsolutePath()));
    com.sun.media.datasink.file.Handler dataSink = new com.sun.media.datasink.file.Handler();
    dataSink.setSource(mux.getDataOutput()); // associate file with mux
    dataSink.setOutputLocator(ml);
    dataSink.open();
    dataSink.start();
    // video only in this sample.
    mux.setNumTracks(1);
    // JPEGFormat was the only kind I got working.
    mux.setInputFormat(format, 0);
    mux.open();
    // Each jpeg goes in a Buffer.
    // When done, buffer must contain EOM flag (and zero length data?).
    Buffer buffer = new Buffer();
    for (int x = 0;; x++)
    read(x, buffer); // read in next file. x is zero index
    mux.doProcess(buffer, 0);
    if (buffer.isEOM())
    break;
    mux.close();
    // close it up
    dataSink.close();
    // Read jpeg image into Buffer
    // id is zero based index of file to get.
    // Always starts at zero and increments by 1
    // Buffer is a jmf structure
    public void read(int id, Buffer buf) throws IOException
    byte b[] = getImageBytes(id);
    if (b == null)
    System.err.println("Done reading all images.");
    // We are done. Set EndOfMedia.
    buf.setEOM(true);
    buf.setOffset(0);
    buf.setLength(0);
    } else
    buf.setData(b);
    buf.setOffset(0);
    buf.setLength(b.length);
    buf.setFormat(format);
    buf.setFlags(buf.getFlags() | Buffer.FLAG_KEY_FRAME);
    }

  • What is the simplest way to create slide show

    What is the simplest way to create a slide show ?  (Premiere Elements 12)

    saploe
    What computer operating system is your Premiere Elements 12 running on? Premiere Elements 12 Mac does not have a Slideshow option in its Elements Organizer 12. So, that situation would not yield the two choices of creating the slideshow in the Elements Organizer and taking it into Premiere Elements OR doing the whole project solely in Premiere Elements.
    What is going into this slideshow....photos (how many, original pixel dimensions), videos (formats and duration), etc?
    What is a description of your computer resources?
    How do you intent to export this slideshow...
    a. burn to DVD-VIDEO standard or widescreen on DVD disc
    b. burn to AVCHD format on DVD disc
    c. burn to Blu-ray disc format on Blu-ray disc
    d. to file saved to the computer hard drive?
    We will customize a reply based on the information that you supply.
    Thanks.
    ATR

  • What is the simplest way to remove duplicates on both iMac and iPad2?

    What is the simplest way to remove duplicate photos from both iMac &amp; iPad2?

    The implication here is that your music is only on the iPod, for if it is in iTunes, you need only do the restore. So you are really asking how you move the music from your iPod back into iTunes, so that when you restore it will go back to the iPod. Take a look at Para. 8 in this summary post I worked up.

  • TS1424 Can you help Plz? What is the simplest way to transfer my music from old computer to new.

    what is the simplest way to transfer my music in iTune from my old computer to the new plz.

    Move or copy the ENTIRE iTunes folder from the old computer to the new computer.

  • What is the simplest way to convert to one page format?

    I have a large file set up as facing pages with the master pages having different margin settings. If I want to change so I will no longer be printing 2-sided output but rather 1-sided, what is the easiest way to change the file? Would I just delete one of the master pages and reset margins?
    Thanks,
    Richard

    Off the top of my head, enable layout adjustment before removing or modifying the master.
    Layout > Layout Adjustment
    Modify the right (?) master (margins).
    Verify changes to the live pages.
    The master does not explicity need to be removed.

Maybe you are looking for

  • How to get one year licence for CE

    I received a mail that developers can use CE for one year. The SDN Subscriptions program is happy to announce that the SAP NetWeaver, Composition Subscription is now available for purchase in Germany and the United States. As a developer, now you hav

  • Laserjet 1300 printer installation

    I got an old laserjet 1300 printer from a friend - no driver or manual included.  Downloaded the driver from the hp website.  My OS is Windows XP.  This printer isn't listed for installation purposes.  I reviewed the manual for compatible drivers, bu

  • Transport of infoset query

    Hi , while i am doing transport in infoset query,i select the infoset and query and next i wnt to transfort and metioned there requried names of infoset &query. i done every thing ok but in SE10 transport organizer ...displaying request  is wrong mis

  • My older version of macbook pro

    i have come to find my donated macbook pro has version version snow leopard 10.6.3 on it presently and was told by the donator that we need to upgrade to mavericks 10.9.... something lol. anyway i already did an update request and it came back saying

  • Premiere Pro crashes when scrolling in Icon View

    Dear Adobe Community, My Premiere Pro CC crashes EVERY TIME when I switch to Icon View from List View, almost as soon as I start scrolling through the Icons/thumbnails. I have all the latest updates for my Mac, Premiere Pro CC and my nVidia CUDA driv