I'm trying to write a Mac OS menu extra application that displays a contextual menu containing the currently active application's menu bar items, when the user presses some hotkey. The displaying of the contextual menu I can do fine, but I can't seem to get the currently active application's menu bar items. At the moment I'm using [[[NSWorkspace sharedWorkspace] runningApplications] filteredArrayUsingPredicate:] to get the active applications' name, but NSRunningApplication seems to contain precious little other information. Is there any way I can get information about application menus from an external application?
UPDATE:
Using the ScriptingBridge framework seems to work fairly well, if you're happy using AppleScript:
    SystemEventsApplication* sevApp = [SBApplication applicationWithBundleIdentifier:@"com.apple.systemevents"];
    SystemEventsProcess* proc = [[sevApp applicationProcesses] objectWithName:appName];
    
    for (SystemEventsMenuBar* menuBar in proc.menuBars) {
        for (SystemEventsMenuBarItem* menuBaritem in menuBar.menuBarItems) {
            NSLog(@"%@", menuBaritem.name);
        }
    }
will print out a list of menus available from the application's menu bar. Haven't found a way to get the contextual menu, so I won't call this answered just yet...
This was useful too: https://robnapier.net/scripting-bridge
 
     
    