This code will tell you where the dock is and how wide it is:
local screenAll,screenAvail
screenAll = rectanglestr(info(“screenrectangle”))
screenAvail = rectanglestr(info(“availablescreenrectangle”))
if array(screenAll,2,",") ≠ array(screenAvail,2,",")
message "The dock is on the right and is " + (val(array(screenAvail,2,","))-val(array(screenAll,2,","))) + " points wide."
elseif array(screenAll,3,",") ≠ array(screenAvail,3,",")
message "The dock is at the bottom and is " + (val(array(screenAll,3,","))-val(array(screenAvail,3,","))) + " points wide."
elseif array(screenAll,4,",") ≠ array(screenAvail,4,",")
message "The dock is on the left and is " + (val(array(screenAll,4,","))-val(array(screenAvail,4,","))) + " points wide."
endif
But you don’t actually need to know anything about the dock. This code will move a window to the right correctly, regardless of where the dock is:
local a,b,c,d,windowtop,dockwidth
getwindow windowtop,b,c,d
zoomalign "left"
getwindow a,b,c,d
dockwidth = b
zoomalign "right"
getwindow a,b,c,d
zoomwindow windowtop,b-dockwidth,c,d,""
… and this (courtesy of Kurt) will move a window to the left correctly, regardless of where the dock is:
local a, b, c, d, dockwidth, screenwidth
getwindow a,b,c,d
screenwidth = val(rectanglestr(info("screenrectangle"))["-,",-1][2,-1])
dockwidth = screenwidth - val(rectanglestr(info("availablescreenrectangle"))["-,",-1][2,-1])
zoomalign "left"
zoomwindow a,dockwidth,c,d,""
You can see that there are two ways of moving the window - Kurt’s code takes 6 lines, mine takes eight.