Anyone have python code to do this? It would make for a nice plugin
closest thing I found has been...
Code: Select all
# Copyright 2010, Trent Nelson ([email protected]).
# $Id: fix-window-placements.py 6 2010-08-10 09:58:58Z Trent $
from win32gui import (
SetFocus,
MoveWindow,
EnumWindows,
GetClassName,
GetWindowRect,
GetWindowText,
IsWindowEnabled,
IsWindowVisible,
GetDesktopWindow,
GetWindowPlacement,
)
from ctypes import (
windll,
c-int,
c-long,
c-ulong,
c-double,
POINTER,
Structure,
WINFUNCTYPE,
)
class RECT(Structure):
-fields- = [
('left', c-long),
('top', c-long),
('right', c-long),
('bottom', c-long)
]
def dump(self):
return map(int, (self.left, self.top, self.right, self.bottom))
MonitorEnumProc = WINFUNCTYPE(c-int, c-ulong, c-ulong, POINTER(RECT),
c-double)
def enum-display-monitors():
results = []
def -callback(monitor, dc, rect, data):
results.append(rect.contents.dump())
return 1
callback = MonitorEnumProc(-callback)
temp = windll.user32.EnumDisplayMonitors(0, 0, callback, 0)
return results
def get-desktop-area():
left = top = right = bottom = 0
for r in enum-display-monitors():
if r[0] < left:
left = r[0]
if r[1] < top:
top = r[0]
if r[2] right = r[2]
if r[3] bottom = r[3]
return (left, top, right, bottom)
def inside-desktop(hwnd):
desktop = get-desktop-area()
rect = GetWindowPlacement(hwnd)[4]
return (
rect[0] rect[1] rect[2]