Activate menubar menu programatically?

  • I'm trying to get one of my menubar menus to show up when a specific
    action is taken, but cannot seem to figure out how.  I have tried the
    following, but nothing happens:

    NSEvent* event = [NSEvent mouseEventWithType: NSLeftMouseDown
                            location: NSMakePoint(100.0, 10.0)
                            modifierFlags: 0
                            timestamp: 0
                            windowNumber: 0
                            context: [NSGraphicsContext currentContext]
                            eventNumber: 0
                            clickCount: 1
                            pressure: 1.0];
    [NSApp mouseDown:event];

    I am winging most the arguments passed in to mouseEventWithType.  I
    have also looked for a way to cal performClick, but to no avail.

    Any suggestions would be greatly appreciated.
  • You can use UI scripting in Applescript to programmatically activate
    your menu. It seems to work fine for me for basic menu manipulation. It
    starts experiencing problems when you try to use it to manipulate other user
    interface items.

    ...Eric Crichlow...
    ...Interwrite Learning...

    Justin Hawkwood wrote:

    I'm trying to get one of my menubar menus to show up when a specific
    action is taken, but cannot seem to figure out how.  I have tried the
    following, but nothing happens:

        NSEvent* event = [NSEvent mouseEventWithType: NSLeftMouseDown
                            location: NSMakePoint(100.0, 10.0)
                            modifierFlags: 0
                            timestamp: 0
                            windowNumber: 0
                            context: [NSGraphicsContext currentContext]
                            eventNumber: 0
                            clickCount: 1
                            pressure: 1.0];
        [NSApp mouseDown:event];

    I am winging most the arguments passed in to mouseEventWithType.  I
    have also looked for a way to cal performClick, but to no avail.

    Any suggestions would be greatly appreciated.
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today