SysGet mon, MonitorWorkArea
Sorry for the noise.
I left the original message below.
---
Althought I found some related topics, I have not seen a function that just return the usable desktop area, ie. the desktop area minus the taskbar and various other possible toolbars.
It can be useful to snap windows to a side of this area, for example (a limitation of Titan's WindowSizing inspired this hack).
So I made this function, designed to be simple to use and fast: I compute the values once, then "cache" them and return them on demand. I had to do that because AutoHotkey cannot return an array or a structure.
/* // Call this function with "x", "y", "w" or "h" parameter // to get respectively the top-left coordinates of the desktop area, // its width or its height. // The "desktop area" is the screen minus docked toolbars like the taskbar. */ GetDesktopArea(p) { static sbSet, sX, sY, sW, sH If not sbSet { ; http://support.microsoft.com/support/kb/articles/Q154/8/23.asp ; RECT structure: left, top, right, bottom VarSetCapacity(desktopAreaRect, 16) DllCall("SystemParametersInfo" , "UInt", 0x30 ; uiAction=SPI_GETWORKAREA , "UInt", 0 ; uiParam , "UInt", &desktopAreaRect ; PVOID pvParam , "UInt", 0) ; fWinIni sX := GetLong(desktopAreaRect, 1) sY := GetLong(desktopAreaRect) sW := GetLong(desktopAreaRect) - sX sH := GetLong(desktopAreaRect) - sY sbSet := true } IfEqual p, x, Return sX IfEqual p, y, Return sY IfEqual p, w, Return sW IfEqual p, h, Return sH } GetLong(ByRef struct, pos=0) { local sa static sPos If (pos != 0) { ; Reset sPos = pos } Else { ; Next sPos++ } ; Long: 32 bits = 4 bytes sa := &struct + (sPos - 1) * 4 Return *sa + (*(sa+1) << 8) + (*(sa+2) << 16) + (*(sa+3) << 24) }
Test:
x := GetDesktopArea("x") y := GetDesktopArea("y") w := GetDesktopArea("w") h := GetDesktopArea("h") MsgBox %x% - %y% - %w% - %h%Easy enough? :-)