candale icon

Python Brgin Window To Front

candale | PRO | 06/13/14 11:56:48 AM UTC | 0 ⭐ | 380 👁️ | Never ⏰ | []
text |

410 B

|

None

|

0 👍

/

0 👎

def RaiseWindowNamed(nameRe):
  import win32gui
  # start by getting a list of all the windows:
  cb = lambda x,y: y.append(x)
  wins = []
  win32gui.EnumWindows(cb,wins)
   # now check to see if any match our regexp:
  tgtWin = -1
  for win in wins:
    txt = win32gui.GetWindowText(win)
    if nameRe.match(txt):
      tgtWin=win
      break
   if tgtWin>=0:
    win32gui.SetForegroundWindow(tgtWin)

Comments