Hi Neophyte.
I currently have no intention of installing anything beyond Mojave, so I can’t test your code in context.
I think ‘window of desktop’ is a relic from the past which has just happened to work up till now as a way of addressing the desktop screen. Looking at the Finder’s dictionary, neither the desktop object nor the container class from which it inherits has a ‘window’ property. It does have a ‘container window’ property which produces the same result as your code in Mojave. It may be worth trying that as a first step.
For the past three years, I’ve been using an ASObjC method to get the main screen’s dimensions:
use AppleScript version "2.4" -- Mac OS 10.10 (Yosemite) or later.
use framework "Foundation"
use framework "AppKit"
use scripting additions
set screenFrame to current application's class "NSScreen"'s mainScreen()'s frame()
But even this is problematic. Before Mojave, it returned an AppleScript record which looked like this:
{origin:{x:0.0, y:0.0}, |size|:{width:2560.0, height:1440.0}}.
In Mojave (and presumably later), it returns a list which looks like this:
{{0.0, 0.0}, {2560.0, 1440.0}}
I’ve only needed the screen height and I’ve been able to get this on both my Mojave and El Capitan machines by adding the following line to the code above:
set screenHeight to current application's NSHeight(screenFrame) as integer
This works whether screenFrame is a list or a record — or did until last week! Since the latest Mojave security update, invoking the NSHeight() function has caused the script to quit silently — but only when it’s run directly from the system script menu. It still works perfectly when run in a script editor or as an application in its own right and another script using a library containing exactly the same code has no problem when run from the script menu. Don’t ask me if this is a bug or another security precaution! Rather than turn the problem script into an application, I’ve replaced the NSHeight() line with good old vanilla AS:
if (screenFrame's class is record) then
set screenHeight to screenFrame's |size|'s height as integer
else if (screenFrame's class is list) then
set screenHeight (item 2 of item 2 of screenFrame) as integer
end if