Explorer Shell extensions are here!

R

R.Marquez

I just happened to bump into this today when I went to the Win32
Python Extensions page. I think the M.H. and his team are a bit too
modest.

Quote:
"win32com.shell grows many more interfaces, allowing Python to operate
as a nearly complete shell extension, and to interact with the shell
interfaces. See the win32comext\shell\demos\server directory for
examples."

This is something I had been waiting for a while, and even submited a
"feature request" about it. So, since I hadn't heard any thing about
it, I figure there may be a few more like me that would enjoy knowing
about this.

(Now, if I could only figure out how to make a context menu that would
show up for any file of folder... ;)

-Ruben
 
J

Joe Francia

R.Marquez said:
I just happened to bump into this today when I went to the Win32
Python Extensions page. I think the M.H. and his team are a bit too
modest.

Quote:
"win32com.shell grows many more interfaces, allowing Python to operate
as a nearly complete shell extension, and to interact with the shell
interfaces. See the win32comext\shell\demos\server directory for
examples."

This is something I had been waiting for a while, and even submited a
"feature request" about it. So, since I hadn't heard any thing about
it, I figure there may be a few more like me that would enjoy knowing
about this.

I _do_ enjoy knowing about this ;>) Thanks for the tip.
(Now, if I could only figure out how to make a context menu that would
show up for any file of folder... ;)

In the demo "context_menu.py", replace the register and unregister bits
with the code below. Run context_menu.py with either the --register or
--unregister switch, as appropiate.

def DllRegisterServer():
import _winreg
folder_key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT,
"Folder\\shellex")
folder_subkey = _winreg.CreateKey(folder_key, "ContextMenuHandlers")
folder_subkey2 = _winreg.CreateKey(folder_subkey, "PythonSample")
_winreg.SetValueEx(folder_subkey2, None, 0, _winreg.REG_SZ,
ShellExtension._reg_clsid_)

file_key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT,
"*\\shellex")
file_subkey = _winreg.CreateKey(file_key, "ContextMenuHandlers")
file_subkey2 = _winreg.CreateKey(file_subkey, "PythonSample")
_winreg.SetValueEx(file_subkey2, None, 0, _winreg.REG_SZ,
ShellExtension._reg_clsid_)

print ShellExtension._reg_desc_, "registration complete."

def DllUnregisterServer():
import _winreg
try:
folder_key = _winreg.DeleteKey(_winreg.HKEY_CLASSES_ROOT,

"Folder\\shellex\\ContextMenuHandlers\\PythonSample")
file_key = _winreg.DeleteKey(_winreg.HKEY_CLASSES_ROOT,

"*\\shellex\\ContextMenuHandlers\\PythonSample")
except WindowsError, details:
import errno
if details.errno != errno.ENOENT:
raise
print ShellExtension._reg_desc_, "unregistration complete."

Peace,
Joe
 
J

John J. Lee

(Now, if I could only figure out how to make a context menu that would
show up for any file of folder... ;)

You can do shell extension stuff quite easily with ctypes, too.
There's a good O'Reilly book on the subject (based on VB, but that
doesn't matter). Use the CVS version, not the tarball, there's at
least one important COM bug fixed there.

One tip: some common COM interfaces don't have type libraries, but
it's easy to write your own interface specifications for ctypes, just
by following the very readable output of the ctypes script (equivalent
of gen_py in win32com) that usually does this job for you.


John
 
R

R.Marquez

Great! That is just what I needed. Thank you, M.H. and all other
Pythonistas for all your great work and generous spirit.

-Ruben
 
R

R.Marquez

(e-mail address removed) (R.Marquez) writes:
You can do shell extension stuff quite easily with ctypes, too.
There's a good O'Reilly book on the subject (based on VB, but that
doesn't matter). Use the CVS version, not the tarball, there's at
least one important COM bug fixed there.

One tip: some common COM interfaces don't have type libraries, but
it's easy to write your own interface specifications for ctypes, just
by following the very readable output of the ctypes script (equivalent
of gen_py in win32com) that usually does this job for you.

John,

I appreciate the tip. I'll have to take a deeper look at ctypes as well.

-Ruben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,781
Messages
2,569,619
Members
45,311
Latest member
ketoCutSupplement

Latest Threads

Top