Applescript, multiple monitors and maximum window sizes

I'm looking at managing Windows on OS X (trying to achieve something like WinSplit Revolution), and I need to use applescript to pull out the maximum window size on this monitor. Currently, I have found:

tell application "Safari"
    set screen_width to (do JavaScript "screen.availWidth" in document 1)
    set screen_height to (do JavaScript "screen.availHeight" in document 1)
end tell

This works for the primary monitor when setting up multiple monitors, but does not provide for secondary monitors at all. I also read the method here, and this obviously does not work for multiple displays in an efficient way. Is there an efficient way to get the maximum window size of multiple displays using applescript?

+3
source share
1 answer

, plist. . http://macscripter.net/viewtopic.php?id=15425

AppleScript studio (ASS), NSScreen, , . ASS AppleScript - ASS Xcode. ASS ASSAccess, ASS:

tell application "ASSAccess"
    -- The first item in this list will be your main monitor
    set screensArray to call method "screens" of class "NSScreen"

    set Displays to {}
    if {} is not screensArray then
        repeat with displayNo from 1 to (count screensArray)
                    -- call visibleFrame instead to take into account the Dock and menubar
            set dims to call method "frame" of (item displayNo of screensArray)
            copy dims to end of Displays
        end repeat
    end if
end tell

, , - . NSScreen LOWER . . , , . , .

+2

Source: https://habr.com/ru/post/1703386/


All Articles