NOTE: Under Construction - I'm in the middle of upgrading my site and lots of stuff is kinda broken. Please forgive the mess.

Get Coordinates For Windows With Mac's JavaScript For Automation

March 2023

This pulls the window coordinates for a single app.

#!/usr/bin/env osascript -l JavaScript

const appName = "iTerm2";
const windowCount = Application(appName).windows.length;

for (let windowIndex = 0; windowIndex < windowCount; windowIndex ++) {
    const window = Application(appName).windows[windowIndex];
    const windowBounds = Application(appName).windows[windowIndex].bounds();
      `x: ${windowBounds.x} - y: ${windowBounds.y} - width: ${windowBounds.width} - height: ${windowBounds.height}`

NOTE: This may not work with all apps. When setting window positions a different method needs to be used.

═══ § ═══