[python-win32] Bringing an external initiated/called window to foreground/focus?
mc@mclaveau
mc at mclaveau.com
Wed Mar 19 20:47:45 CET 2014
Hi!
Below, a little code for set to foreground windows who have two
sub-string in their title.
@-salutations & sorry for my bad english.
--
Michel Claveau
------------------------------------------------------------------------
# -*- coding: utf-8 -*-
import win32gui
def win_premierplan_h(hwin, r):
st=win32gui.GetWindowText(hwin)
if st.find(r[0])>-1 and st.find(r[1])>-1:
if hwin!=0:
try:
win32gui.SetForegroundWindow(hwin)
except:
pass
def win_premierplan(r1,r2):
"""
Met au premier plan les fenêtres dont le titre contient les deux
chaînes-repères r1 et r2
utiliser des chaines-repères en Unicode
"""
win32gui.EnumWindows(win_premierplan_h,(r1,r2))
win_premierplan("C:\\","")
win_premierplan("My","Pic")
------------------------------------------------------------------------
Le 19.03.14 11:32, Jacob Kruger a écrit :
> 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..."
>
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> https://mail.python.org/mailman/listinfo/python-win32
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20140319/49116e8d/attachment.html>
More information about the python-win32
mailing list