12 |
|
|
13 |
import pythoncom |
import pythoncom |
14 |
from win32com.shell import shell, shellcon |
from win32com.shell import shell, shellcon |
15 |
import win32gui |
import win32gui, win32gui_struct |
16 |
import win32con |
import win32con |
17 |
import win32api, winerror |
import win32api, winerror |
18 |
|
|
53 |
self.files_selected.append(fname) |
self.files_selected.append(fname) |
54 |
|
|
55 |
# build context menu(s) |
# build context menu(s) |
56 |
msg = "A&rchiveMe" |
msg = "Add to A&rchive" |
57 |
idCmd = idCmdFirst |
idCmd = idCmdFirst |
58 |
items = [] |
items = [] |
59 |
if (uFlags & 0x000F) == shellcon.CMF_NORMAL: # Check == here, since CMF_NORMAL=0 |
if (uFlags & 0x000F) == shellcon.CMF_NORMAL: # Check == here, since CMF_NORMAL=0 |
75 |
print "** unknown flags", uFlags |
print "** unknown flags", uFlags |
76 |
items.append("hello world - 2!") |
items.append("hello world - 2!") |
77 |
|
|
78 |
# create menu entries |
# add seperator line |
79 |
win32gui.InsertMenu(hMenu, indexMenu, |
win32gui.InsertMenu(hMenu, indexMenu, |
80 |
win32con.MF_SEPARATOR|win32con.MF_BYPOSITION, |
win32con.MF_SEPARATOR|win32con.MF_BYPOSITION, |
81 |
idCmd, None) |
idCmd, None) |
82 |
indexMenu += 1 |
indexMenu += 1 |
83 |
idCmd += 1 |
idCmd += 1 |
84 |
|
|
85 |
|
# create main menu entries |
86 |
for item in items: |
for item in items: |
87 |
win32gui.InsertMenu(hMenu, indexMenu, |
win32gui.InsertMenu(hMenu, indexMenu, |
88 |
win32con.MF_STRING|win32con.MF_BYPOSITION, |
win32con.MF_STRING|win32con.MF_BYPOSITION, |
89 |
idCmd, item) |
idCmd, item) |
90 |
indexMenu += 1 |
indexMenu += 1 |
91 |
idCmd += 1 |
idCmd += 1 |
92 |
|
|
93 |
|
# create submenu entries |
94 |
|
hSubmenu = win32gui.CreatePopupMenu() |
95 |
|
win32gui.InsertMenu(hSubmenu, 0, |
96 |
|
win32con.MF_BYPOSITION, |
97 |
|
idCmd, "&Settings...") |
98 |
|
idCmd += 1 |
99 |
|
|
100 |
|
# insert the submenu into a new container menu entry |
101 |
|
item, extras = win32gui_struct.PackMENUITEMINFO( |
102 |
|
wID = idCmd, |
103 |
|
hSubMenu = hSubmenu, |
104 |
|
text = "&Mess" |
105 |
|
) |
106 |
|
win32gui.InsertMenuItem(hMenu, indexMenu, 1, item) |
107 |
|
indexMenu += 1 |
108 |
|
idCmd += 1 |
109 |
|
|
110 |
|
# add seperator line |
111 |
win32gui.InsertMenu(hMenu, indexMenu, |
win32gui.InsertMenu(hMenu, indexMenu, |
112 |
win32con.MF_SEPARATOR|win32con.MF_BYPOSITION, |
win32con.MF_SEPARATOR|win32con.MF_BYPOSITION, |
113 |
idCmd, None) |
idCmd, None) |
114 |
indexMenu += 1 |
indexMenu += 1 |
115 |
idCmd += 1 |
idCmd += 1 |
116 |
|
|
117 |
return idCmd-idCmdFirst # Must return number of menu items we added. |
return idCmd-idCmdFirst # Must return number of menu items we added. |
118 |
|
|
119 |
def GetCommandString(self, cmdId, typ): |
def GetCommandString(self, cmdId, typ): |
133 |
function_id = win32api.LOWORD(verb) |
function_id = win32api.LOWORD(verb) |
134 |
# TODO: establish mapping with building the context menus in "QueryContextMenu" |
# TODO: establish mapping with building the context menus in "QueryContextMenu" |
135 |
if function_id == 1: |
if function_id == 1: |
136 |
method = "ArchiveMe" |
method = "Add to archive" |
137 |
elif function_id == 2: |
elif function_id == 2: |
138 |
method = "Shortcut 1" |
method = "Shortcut 1" |
139 |
elif function_id == 3: |
elif function_id == 3: |