[python-win32] Bringing an external initiated/called window to foreground/focus?

Jim Bell Jim at JC-Bell.com
Wed Mar 19 12:50:14 CET 2014


Find and activate it by matching its window title.

import win32com.client
shell = win32com.client.Dispatch('WScript.Shell')
if shell.AppActivate('Explorer'): # put a better match here.
    print 'Did it.'


On 2014-03-19 5:32 AM, Jacob Kruger wrote:
> If, for example, I use something like following command line 
> call/command to launch an instance of windows explorer, in a specific 
> location, with a specific file highlighted/selected, the issue is that 
> it seems to, possibly be hovering in background/not actually taking 
> focus on my windows7 64 bit machine:
> explorer /select,c:\temp\testFile.txt
> Wondering if there's a relatively simple way to bring a specific, 
> external window/application into foreground focus?
> TIA
>
> Jacob Kruger
> Blind Biker
> Skype: BlindZA
> "Roger Wilco wants to welcome you...to the space janitor's closet..."

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20140319/45bd3491/attachment.html>


More information about the python-win32 mailing list