Advertisement
candale

Python Brgin Window To Front

Jun 13th, 2014
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. def RaiseWindowNamed(nameRe):
  2. import win32gui
  3. # start by getting a list of all the windows:
  4. cb = lambda x,y: y.append(x)
  5. wins = []
  6. win32gui.EnumWindows(cb,wins)
  7.  
  8. # now check to see if any match our regexp:
  9. tgtWin = -1
  10. for win in wins:
  11. txt = win32gui.GetWindowText(win)
  12. if nameRe.match(txt):
  13. tgtWin=win
  14. break
  15.  
  16. if tgtWin>=0:
  17. win32gui.SetForegroundWindow(tgtWin)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement