Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Using hints from <a href="http://www.devx.com/opensource/Article/37773/1954" rel="noreferrer">WindowMover article</a> and <a href="http://our.obor.us/?q=node/42" rel="noreferrer">Nattee Niparnan's blog post</a> I managed to create this:</p> <pre><code>import win32con import win32gui def isRealWindow(hWnd): '''Return True iff given window is a real Windows application window.''' if not win32gui.IsWindowVisible(hWnd): return False if win32gui.GetParent(hWnd) != 0: return False hasNoOwner = win32gui.GetWindow(hWnd, win32con.GW_OWNER) == 0 lExStyle = win32gui.GetWindowLong(hWnd, win32con.GWL_EXSTYLE) if (((lExStyle &amp; win32con.WS_EX_TOOLWINDOW) == 0 and hasNoOwner) or ((lExStyle &amp; win32con.WS_EX_APPWINDOW != 0) and not hasNoOwner)): if win32gui.GetWindowText(hWnd): return True return False def getWindowSizes(): ''' Return a list of tuples (handler, (width, height)) for each real window. ''' def callback(hWnd, windows): if not isRealWindow(hWnd): return rect = win32gui.GetWindowRect(hWnd) windows.append((hWnd, (rect[2] - rect[0], rect[3] - rect[1]))) windows = [] win32gui.EnumWindows(callback, windows) return windows for win in getWindowSizes(): print win </code></pre> <p>You need the <a href="http://python.net/crew/mhammond/win32/Downloads.html" rel="noreferrer">Win32 Extensions for Python module</a> for this to work.</p> <p>EDIT: I discovered that <code>GetWindowRect</code> gives more correct results than <code>GetClientRect</code>. Source has been updated.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload