Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Change The Size Of A Mac Window With JavaScript

This works with one way to make the change but there's a second way as well

Code

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

/*
Application("Google Chrome").windows[0].bounds = {
    "x": 20, "y": 20, "width": 800, "height": 900
}
*/

const appName = "Emacs"

const bounds = Application(appName).windows[0].bounds()

Application(appName).windows[0].bounds = {
// "x": 200, "y": bounds["y"], "width": bounds["width"], "height": bounds["height"]
"x": 10, "y": 100, "width": 900, "height": 500
}