Layouter

.py

Windows disposition for some windows in Windows

"""
Set position and sizes for some windows in Windows
"""

import win32gui

HWND_TOP = 0
SWP_ASYNCWINDOWPOS = 0x4000
SW_SHOWNORMAL = 1

# enumerate top-level windows
def ec(h, r):
    t = win32gui.GetWindowText(h)
    r.append((h, t))
z = []
win32gui.EnumWindows(ec, z)

# common options
hWndInsertAfter = HWND_TOP
uFlags = SWP_ASYNCWINDOWPOS
nCmdShow = SW_SHOWNORMAL

# "<...folder...> - Outlook"
hWnd = next(filter(lambda x: x[1].endswith(' - Outlook'), z))[0]
win32gui.SetWindowPos(hWnd, hWndInsertAfter, 1929, 296, 3447-1929, 1166-296, uFlags)
win32gui.ShowWindow(hWnd, nCmdShow)

# "Lync"
hWnd = next(filter(lambda x: x[1] == 'Lync', z))[0]
win32gui.SetWindowPos(hWnd, hWndInsertAfter, 3454, 124, 3840-3454, 1165-124, uFlags)
win32gui.ShowWindow(hWnd, nCmdShow)