Given a program process (say Visual Studio 2012), how can I access it's menu items programmatically?
I'm not at all sure what APIs I would use or how to even Google this.
Thanks in advance.
Start with GetMenu(): http://msdn.microsoft.com/en-us/library/windows/desktop/ms647640(v=vs.85).aspx and over on the left are all the other menu functions. (Assuming you're talking Win32 API.)
Since it appears you have the process ID, you can find the main window's HWND from here: Win32 - Get Main Wnd Handle of application
unfortunately, more and more programs don't use the traditional "menu" subsystem. The answer given by Graham will work for some simple application, as calc.exe and notepad.exe, but not for VS2012.
I suggest using UIautomation.
The Windows SDks come with an "accessibility" tool, Inspect, that will show you if you can expect good support of UIAutomation by applications.
Microsoft now recommends using Accessibility Insigths instead:
https://learn.microsoft.com/en-us/windows/win32/winauto/inspect-objects?redirectedfrom=MSDN