January 1, 2005

WinTask - AllMenus

'
' AllMenus
'
' Author: Joe Strazzere
'

Dim men$(100)
m1$="                                                                "
m2$="                                                                "
m3$="                                                                "
m4$="                                                                "

idx=-1
hwnd=GetWindowHandle(top$(),1)
hmenu=External("user32","GetMenu", hwnd)
menucount=External("user32", "GetMenuItemCount", hMenu)
i=o
while i < menucount
  External("user32","GetMenuStringA",hmenu,i,m1$,64,-1)
    idx=idx+1
 men$(idx)=m1$
' Comment(m1$)
   hsubmenu=External("user32", "GetSubMenu", hMenu, i)
   submenucount=External("user32", "GetMenuItemCount", hsubMenu)
    j=0
   while j < submenucount
     External("user32","GetMenuStringA",hsubmenu,j,m2$,64,-1)
     If m2$ <> "" then
      idx=idx+1
   men$(idx)=m1$+"|"+m2$
     endif
    hsubsubmenu=External("user32", "GetSubMenu", hsubMenu, j)
    subsubmenucount=External("user32", "GetMenuItemCount", hsubsubMenu)
    k=0
    while k < subsubmenucount
       External("user32","GetMenuStringA",hsubsubmenu,k,m3$,64,-1)
      If m3$ <> "" then
       idx=idx+1
    men$(idx)=m1$+"|"+m2$+"|"+m3$
      endif
     hsubsubsubmenu=External("user32", "GetSubMenu", hsubsubMenu, j)
     subsubsubmenucount=External("user32", "GetMenuItemCount", hsubsubsubMenu)
     l=0
     while l < subsubsubmenucount
        External("user32","GetMenuStringA",hsubsubsubmenu,l,m4$,64,-1)
       If m4$ <> "" then
        idx=idx+1
     men$(idx)=m1$+"|"+m2$+"|"+m3$+"|"+m4$
       endif
     l=l+1
     wend
    k=k+1
    wend
   j=j+1
   wend
i=i+1
wend
i=0
while i <= idx
  comment(men$(i))
  i=i+1
wend
'UseWindow(top$())
' ChooseMenu(Normal,men$(0))
' sendkeys("<Esc><Esc>")
'pause 3 secs
'UseWindow(top$())
' ChooseMenu(Normal,men$(2))