I need to know how to control the menu system of another application from my application. So far, I have gotten this feedback from Matthew Gates, but it only shows how to get the menu system from an application (in this case, Notepad):

Code:
'Code by Aaron Young

Private Declare Function GetMenu Lib "user32" (ByVal hWnd As Long) As Long
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Private Declare Function GetMenuString Lib "user32" Alias "GetMenuStringA" (ByVal hMenu As Long, ByVal wIDItem As Long, ByVal lpString As String, ByVal nMaxCount As Long, ByVal wFlag As Long) As Long

Private Const MF_BYPOSITION = &H400&

Public Sub ListMenuStructure(ByVal hWnd As Long, ByRef oList As ListBox)
    Dim lMenu As Long
    lMenu = GetMenu(hWnd)
    oList.Clear
    If lMenu Then RecurseMenu lMenu, oList, 1
End Sub

Private Sub RecurseMenu(ByVal lMenu As Long, ByRef oList As ListBox, ByVal iLevel As Long)
    Dim lItems As Long
    Dim lItem As Long
    Dim sCaption As String
    lItems = GetMenuItemCount(lMenu)
    If lItems Then
        For lItem = 0 To lItems - 1
            sCaption = Space(255)
            sCaption = Left(sCaption, GetMenuString(lMenu, lItem, ByVal sCaption, 255, MF_BYPOSITION))
            oList.AddItem String((iLevel - 1) * 2, "-") & sCaption
            If GetSubMenu(lMenu, lItem) Then
                RecurseMenu GetSubMenu(lMenu, lItem), oList, iLevel + 1
            End If
        Next
    End If
End Sub

Private Sub Command1_Click()
ListMenuStructure FindWindowEx(0, 0, "NotePad", vbNullString), List1
End Sub

Now I need to know how to control this menu from my application.

Thanks,

Simon Bingier