Skip to content

[AppleScript] Adjust Window Size on Mac OS

Last Updated on 2022-05-10 by Clay

I always use SizeUp tool to split my window to right side or left side. Because when I working I need to check some program info and programming together.

In additional, I also hope to be able to customize a fixed window size to take screenshots, so that it is more convenient to write notes, and it will not be adjusted because the picture is too large or too small.

I think AppleScript can help, but I am still finding a way to automatically adjust the topmost window (activated). After all, the method I have found so far can only be adjusted by specifying a specific app.

The details you can refer the following code.


Set the bounds in Window Attribute

We need to set the following 4 attributes.

  • x: The x position when app startup
  • y: The x position when app startup
  • width: The width of app
  • height: The height of app

(Note: Be careful not to use keywords as variable names)

Suppose we want to resize the Finder window:

set X to 0
set Y to 0
set appWidth to 1200
set appHeight to 1000

tell application "Finder"
	activate
	reopen
	set the bounds of the first window to {X, Y, appWidth, appHeight}
end tell


Output:

https://clay-atlas.com/wp-content/uploads/2021/03/Screen-Recording-2021-03-31-at-4.20.32-PM.mov

This allows us to arbitrarily adjust the window size of the application.


References


Read More

Leave a ReplyCancel reply

Exit mobile version