Форум сайта python.su
Есть такой код:
win32gui.SetForegroundWindow(program[0]) win32gui.SetActiveWindow(program[0])
def make_window_active(my_title): if sys_type=='win': toplist = [] winlist = [] def enum_callback(hwnd, results): winlist.append((hwnd, win32gui.GetWindowText(hwnd))) win32gui.EnumWindows(enum_callback, toplist) program = [(hwnd, title) for hwnd, title in winlist if my_title in title.lower()] # just grab the first window that matches if len(program)>=1: program = program[0] # use the window handle to set focus win32gui.SetForegroundWindow(program[0]) win32gui.SetActiveWindow(program[0])
Офлайн