Have a look through this script:
https://github.com/morganloomis/ml_tools/blob/master/scripts/ml_toolbox.py
The main menu bar is stored in an global variable, then you can query menu items using the regular menu command.
The one gotcha is that some menus aren't built until the first time you click on them, but you can query and run the assigned postMenuCommand in order to pre-build them, which is also in the script.