Paldies Šiem vāciski runājošajiem puišiem.
import win32gui from win32con import * from ctypes import * MONITOR_DEFAULTTONULL = 0 MONITOR_DEFAULTTOPRIMARY = 1 MONITOR_DEFAULTTONEAREST = 2 MonitorFromWindow = windll.user32.MonitorFromWindow GetMonitorInfo = windll.user32.GetMonitorInfoA SubtractRect = windll.user32.SubtractRect GetWindowRect = windll.user32.GetWindowRect 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)) class MONITORINFO(Structure): _fields_ = [ ('cbSize', c_ulong), ('rcMonitor', RECT), ('rcWork', RECT), ('dwFlags', c_ulong) ] def __init__(self): Structure.__init__(self) self.cbSize = sizeof(MONITORINFO) def windowSize(): hwnd = win32gui.FindWindow('Shell_TrayWnd', None) mon = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST) mon_info = MONITORINFO() GetMonitorInfo(mon, pointer(mon_info)) workArea = RECT() taskbarRect = RECT() GetWindowRect(hwnd, byref(taskbarRect)) SubtractRect(byref(workArea), byref(mon_info.rcMonitor), byref(taskbarRect)) return (workArea.left, workArea.top, workArea.right, workArea.bottom); print windowSize();
Comments