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

Augusts 2017

7d 1d 2d 3d 4d 5d 6d
  12345
6789101112
13141516171819
20212223242526
2728293031  
Powered by Sviesta Ciba