title: How to programmatically select popup menu item in Windows?
body: <p>I have an app that I'm writing a little wizard for.  It automated a small part of the app by moving the mouse to appropriate buttons, menus and clicking them so the user can watch.</p>
  
  <p>So far it moves the mouse to a tree item and sends a right-click.  That pops up a menu via TrackPopupMenu.  Next I move the mouse to the appropriate item on the popup menu.  What I can't figure out is how to select the menu item.</p>
  
  <p>I've tried sending left-clicks to the menu's owner window, tried sending WM_COMMAND to the menu's owner, etc.  Nothing works.</p>
  
  <p>I suppose the menu is a window in and of itself, but I don't know how to get the HWND for it from the HMENU that I have.</p>
  
  <p>Any thoughts on how to PostMessage a click to the popup menu?</p>
  
  <p>PS I'm using a separate thread to drive the mouse and post messages, so no problems with TrackPopupMenu being synchronous.</p>