def __call__(self, x, y, displayNumber=0):
     monitorDimensions = GetMonitorDimensions()
     try:
         displayRect = monitorDimensions[displayNumber]
     except IndexError:
         displayRect = monitorDimensions[0]
     rect = RECT()
     mons = EnumDisplayMonitors(None, None)
     mons = [item[2] for item in mons]
     for hwnd in GetTopLevelOfTargetWindows():
         GetWindowRect(hwnd, byref(rect))
         X = rect.left
         Y = rect.top
         for mon in range(len(mons)):
             if mons[mon][0] <= X and X <= mons[mon][2] and mons[mon][
                     1] <= Y and Y <= mons[mon][3]:
                 break
         if mon == len(mons):
             mon = 0
         if x is None:
             x = rect.left - mons[mon][0]
         if y is None:
             y = rect.top - mons[mon][1]
         x += displayRect[0]
         y += displayRect[1]
         MoveWindow(hwnd, x, y, rect.right - rect.left,
                    rect.bottom - rect.top, 1)
    def __call__(self, h, v, hwnd=None):
        hwnd = GetBestHwnd(hwnd)
        win = GetWindowDimensions(hwnd)
        mon, i = GetContainingMonitor(win)

        # Choose horizontal position
        if h == 1:
            x = mon.left
        elif h == 2:
            x = mon.left + (mon.width / 2) - (win.width / 2)
        elif h == 3:
            x = mon.left + mon.width - win.width
        else:
            x = win.left

        # Choose vertical position
        if v == 1:
            y = mon.top
        elif v == 2:
            y = mon.top + (mon.height / 2) - (win.height / 2)
        elif v == 3:
            y = mon.top + mon.height - win.height
        else:
            y = win.top

        # Move window to the specified location
        MoveWindow(hwnd, x, y, win.width, win.height, 1)
 def __call__(self, width=None, height=None):
     rect = RECT()
     for hwnd in GetTopLevelOfTargetWindows():
         GetWindowRect(hwnd, byref(rect))
         if width is None:
             width = rect.right - rect.left - 1
         if height is None:
             height = rect.bottom - rect.top - 1
         MoveWindow(hwnd, rect.left, rect.top, width + 1, height + 1, 1)