Zoomalign and rectanglealign anomalies


#21

It may be obsolete but it’s not deprecated so I thought it would be OK to use.

info(“windowrectangle”) would work also, you just have to adjust its output to exclude the height of the menu bar. getwindow is much easier.

I have to run off to see the doctor but I’ll get back to the other issues shortly.


#22

This puts a corrected value in a variable named AvailableScreen.

Local AvailableScreen
AvailableScreen = rectangleoffset(info("availablescreenrectangle"), 0,
    rright(info("screenrectangle"))-rright(info("availablescreenrectangle"))+
    rleft(info("screenrectangle"))-rleft(info("availablescreenrectangle")))

zoomwindowrectangle rectanglealign(AvailableScreen,info(“windowrectangle”),“right”)
// zoomwindowrectangle rectanglealign(AvailableScreen,info(“windowrectangle”),“left”)

At least it does with one monitor. I don’t know how it works with two


#23

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.


#24

Left and right are swapped in the current version of Apple’s code. My code recognises this and utilises it. The problem is that, if Apple ever makes its code work properly, this solution will give incorrect results. Anybody using it needs to remember that.


#25

I should have mentioned that Kurt’s code is based on that same anomaly and is subject to the same future problem.