[python-win32] Win7 explorer "include in library" submenu

Chris Ness karbonforms at gmail.com
Sat May 26 12:52:11 CEST 2012


I'm trying to replicate the win 7 explorer context menu on the fly. All 
works well apart from the "Include in Library" submenu, which shows one 
greyed out entry: "retrieving libraries...". Well it's not retrieving 
anything because the code to read the menus has returned! Here is my 
code that reads the menu entries...

def __getMenuItems(hMenu, contextMenu):
     num_items = win32gui.GetMenuItemCount(hMenu)
     rval = []
     for i in range(num_items):
         mi = EmptyMENUITEMINFO()
         win32gui.GetMenuItemInfo(hMenu, i, True, mi[0])
         item = UnpackMENUITEMINFO(mi[0])
         fType, fState, wID, hSubMenu, hbmpChecked, hbmpUnchecked, dwItemData, text, hbmpItem = item
         if hSubMenu:
             hSubMenu = win32gui.GetSubMenu(hMenu, i)
             rval.append((__getMenuItems(hSubMenu, contextMenu), text))
         else:
             rval.append((wID, text))
     return rval


I have no idea what to do and google is no help. Do I need to initiate 
something? Wait for something? Any help much appreciated!

chris



More information about the python-win32 mailing list