def set_window_top(): hwnd = win32gui.GetForegroundWindow() (left, top, right, bottom) = win32gui.GetWindowRect(hwnd) win32gui.SetWindowPos(hwnd, win32con.HWND_TOPMOST, left, top, right - left, bottom - top, 0)