Radu Ciora wrote: > Is it possible to get a handle to a running application like the one I get > when I explicitly start an application myself using the > win32com.client.Dispatch("Object.Name")? > > Is the one retrieved by win32gui.GetForegroundWindow() the same as the one > above or not, if not how can I get the handle to a running application object. > > I hope I made myself understand. >
Well, you are confusing several very different constructs there. What you get back from win32com.client.Dispatch is not a handle at all; it is a pointer to a COM object. It contains methods and properties that you can call directly. What you get back from win32gui.GetForegroundWindow is just a window handle. You can send window messages to it, but there is nothing there to call, and there is no connection to any COM objects. In fact, there is no guarantee that the foreground application offers any COM services at all. Having said that, I assume that what you really want to do, for example, is to connect to a currently running instance of Word. Is that right? Somewhat surprisingly, this depends on the application. For the Office products, if you do a Dispatch on Word.Application while Word is running, you should get a pointer to the existing Word application, and should be able to manipulate the existing documents. For other applications, the answer is "it depends". -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32