1. Maijs 2006, 02:00 |
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();
| 7d | 1d | 2d | 3d | 4d | 5d | 6d |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | 31 |