May be you know the following already, but FWIW:
IIRC, QS used MacOS X's Accessibility API for this (at least at one point). For Windows, there's:
http://msdn.microsof...indows/bb735024.aspxwith interesting-sounding tibdits like "UI Automation". Don't know if any of that would be useful in the current context though.
AHK has WinMenuSelectItem and here's some extract from its docs:
...However, some windows might need to be in a non-minimized state.
This command will not work with applications that use non-standard menu bars. Examples include Microsoft Outlook and Outlook Express, which use disguised toolbars for their menu bars. In these cases, consider using ControlSend or PostMessage , which should be able to interact with some of these non-standard menu bars.
May be some of those things in combination with %LASTHWND% would let a plugin or alias do something relevant.