January 1, 2005

WinTask - MenuDump

'
' MenuDump
'
' Author: Joe Strazzere
'

menustring$="                                                                "

hwnd=GetWindowHandle(top$(),1)
hmenu=External("user32","GetMenu", hwnd)
menucount=External("user32", "GetMenuItemCount", hMenu)
i=o
while i < menucount
  External("user32","GetMenuStringA",hmenu,i,menustring$,64,-1)
 Comment(menustring$)
   hsubmenu=External("user32", "GetSubMenu", hMenu, i)
   submenucount=External("user32", "GetMenuItemCount", hsubMenu)
    j=0
   while j < submenucount
     External("user32","GetMenuStringA",hsubmenu,j,menustring$,64,-1)
     If menustring$ = "" then
      Comment("    ----- Separator -----")
     else
      Comment("    "+menustring$)
     endif
    hsubsubmenu=External("user32", "GetSubMenu", hsubMenu, j)
    subsubmenucount=External("user32", "GetMenuItemCount", hsubsubMenu)
    k=0
    while k < subsubmenucount
       External("user32","GetMenuStringA",hsubsubmenu,k,menustring$,64,-1)
      If menustring$ = "" then
        Comment("        ----- Separator -----")
      else
        Comment("        "+menustring$)
      endif
     hsubsubsubmenu=External("user32", "GetSubMenu", hsubsubMenu, j)
     subsubsubmenucount=External("user32", "GetMenuItemCount", hsubsubsubMenu)
     l=0
     while l < subsubsubmenucount
        External("user32","GetMenuStringA",hsubsubsubmenu,l,menustring$,64,-1)
       If menustring$ = "" then
         Comment("            ----- Separator -----")
       else
         Comment("            "+menustring$)
       endif
     l=l+1
     wend
    k=k+1
    wend
   j=j+1
   wend
i=i+1
wend