Tim, Mike Driscoll wrote: > > I am trying to get a handle on an external process (Internet Explorer 6 in > > this case) that I open using win32process. I need the handle so that I can > > make said process the top window.
> When you call CreateProcess, that window should automatically become the > top window. Are you saying that's not happening? Have you tried > creating a STARTUPINFO struct and filling in the wShowWindow element? Sorry, I guess I thought more than I actually typed. It does make the newly created window the top window. But later on in my program, I open the source code for the displayed page and will need to make sure that I return to the correct IE instance, which is why I wanted a handle on the IE window. I thought I knew the correct terminology to express this, but I guess not. <snip> > > > > # attempt to make Internet Explorer 6 the Foreground Window > > win32gui.SetForegroundWindow(handle) > > > No, the error message is right. A process handle is not the same as a > window handle. Indeed, a process need not have any windows at all. > > I can get the handle by doing this: > > > > hwnd = win32gui.FindWindow('IEFrame',None) > > > > But if there's multiple Explorer windows open, I may not get the window I > > want. That's why I would like to create my own so I can have what amounts > > to an "exclusive" handle to it. Any hints would be appreciated. > > > One possibility is to enumerate through all of the top-level windows > using EnumWindows, and for each window call GetWindowThreadProcessId to > find the process ID associated with that window to find the one that > matches your process. Remember that the process ID is not the same as a > process handle; the process ID is the third thing in the tuple > CreateProcess returns. Yeah, I am well aware of this method and was hoping to avoid it. Thanks for the clarification on window handle versus process handle. I was thinking about this the wrong way because I thought they were the same. > -- > Tim Roberts, [EMAIL PROTECTED] > Providenza & Boekelheide, Inc. Mike Driscoll Applications Specialist MCIS - Technology Center _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32