Never do anything API without consulting pinvoke.net (although it's VB declarations do tend to be a bit on the old fashioned side!) Here's there sample for GetMenu
vb.net Code:
Dim hwndMain as IntPtr = FindWindowEx(intptr.Zero,intptr.Zero,vbNullString,"My Window Title") 'Get the Window Handle Dim hwndMenu As IntPtr = GetMenu(hwndMain) 'Get the MenuHandle Dim hwndSubmenu as intptr = GetSubMenu(hwndMenu,1) 'Get the SubMenuHandle to the visible MenuItem, in this case the second one (counting from zero) Dim intMID as Integer = GetMenuitemID(hwndSubmenu,2)) 'Get the MenuItemID of the third SubMenu under the previous Handle (counting from zero) Sendmessage(hwndMain, WM_COMMAND, intMID, 0) 'Click the MenuItem!




Reply With Quote