Get available screen area in autohotkey Get available screen area in autohotkey windows windows

Get available screen area in autohotkey


I got something working in XP. It currently only takes into consideration the taskbar, so it probably won't do the right thing in Vista when the sidebar is visible. However, it does work regardless of where the toolbar is.

Here are the methods I created, along with a simple ResizeAndCenter method that shows their use:

; Gets the edge that the taskbar is docked to.  Returns:;   "top";   "right";   "bottom";   "left"GetTaskbarEdge() {  WinGetPos,TX,TY,TW,TH,ahk_class Shell_TrayWnd,,,  if (TW = A_ScreenWidth) { ; Vertical Taskbar    if (TY = 0) {      return "top"    } else {      return "bottom"    }  } else { ; Horizontal Taskbar    if (TX = 0) {      return "left"    } else {      return "right"    }  }}GetScreenTop() {  WinGetPos,TX,TY,TW,TH,ahk_class Shell_TrayWnd,,,  TaskbarEdge := GetTaskbarEdge()  if (TaskbarEdge = "top") {    return TH  } else {    return 0  }}GetScreenLeft() {  WinGetPos,TX,TY,TW,TH,ahk_class Shell_TrayWnd,,,  TaskbarEdge := GetTaskbarEdge()  if (TaskbarEdge = "left") {    return TW  } else {    return 0  }}GetScreenWidth() {  WinGetPos,TX,TY,TW,TH,ahk_class Shell_TrayWnd,,,  TaskbarEdge := GetTaskbarEdge()  if (TaskbarEdge = "top" or TaskbarEdge = "bottom") {    return A_ScreenWidth  } else {    return A_ScreenWidth - TW  }}GetScreenHeight() {  WinGetPos,TX,TY,TW,TH,ahk_class Shell_TrayWnd,,,  TaskbarEdge := GetTaskbarEdge()  if (TaskbarEdge = "top" or TaskbarEdge = "bottom") {    return A_ScreenHeight - TH  } else {    return A_ScreenHeight  }}ResizeAndCenter(w, h){  ScreenX := GetScreenLeft()  ScreenY := GetScreenTop()  ScreenWidth := GetScreenWidth()  ScreenHeight := GetScreenHeight()  WinMove A,,ScreenX + (ScreenWidth/2)-(w/2),ScreenY + (ScreenHeight/2)-(h/2),w,h}


Have you tried using SysGet's MonitorWorkArea sub-command?
http://www.autohotkey.com/docs/commands/SysGet.htm