Daniel Gonçalves wrote:
Hi!
I need to find the selected file(s) in a Windows Explorer window from
another program (I'd look at the window that last had focus). I found
something in the following page that should do the trick:
http://blogs.msdn.com/oldnewthing/archive/2004/07/20/188696.aspx
However, it is not Python and, while I'm a competent Python
programmer, Win32, COM and the like are somewhat outside my
competences.
WOW, that's fairly amazing. It takes 9 different COM interfaces to get
this information.
Does any one know how to do something similar in Python (maybe in a
more Pythonic way?)
Unfortunately, it's not a Pythonic task. It's a Windows task. I can
give you some hints to get you started, but it's going to be a tedious
task with lots of trial and error.
import pywintypes
import win32com.client
CLSID_ShellWindows = pywintypes.IID( '{9ba05972-f6a8-11cf-a442-00a0c90a8f39}' )
o = win32com.client.Dispatch( CLSID_ShellWindows )
for i in range(o.Count):
print o.Item(0).Name
Now you have an IID_ShellWindows interface. You can use o.Count to find
out how many windows there are, and o.Item(i) will return you each
window in the collection one at a time. From there, you'll need to
query the appropriate subinterfaces, and hope that they are all dispatch
interfaces so they can be used from Python.
I might be tempted to take the C++ code and make a simple extension DLL.
Perhaps Mark or Tim Golden has some better hints.
--
Tim Roberts, [EMAIL PROTECTED]
Providenza & Boekelheide, Inc.
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32