Skip to content

Instantly share code, notes, and snippets.

@ChristopherA
Last active January 6, 2024 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChristopherA/e8b2b4e0b4de6fd0fb71d4d759d8bde8 to your computer and use it in GitHub Desktop.
Save ChristopherA/e8b2b4e0b4de6fd0fb71d4d759d8bde8 to your computer and use it in GitHub Desktop.
AppleScript: Frontmost Window to 720p
(*
System: Frontmost Window to 720p
By Christopher Allen (@ChristopherA)
This applescript will attempt to resize the frontmost window of the frontmost app
to 720p (16:9) less menu bar height to ease video recording. It is particularly designed
for applications that don't otherwise support Applescript events.
Requires Script Menu: turn on inside the "Script Editor" app (in ~/Applications/Utilities/),
"Settings…", "General" tab, and turn on "Script Menu: Show Script menu in menu bar"
Script Menu also will require Assistive Accessiblity permissions "System Settings",
search for "allow assistive", and add both `Script Editor` (in ~/Applications/Utilities)
and `Script Menu` in `/System/Applications/Utilities/Script Editor.app`
Save this in ~/Library/Scripts/Frontmost\ Window\ to\ 720p.scpt
The first time you use this script you'll need to give the Script Menu accessiblity permissions.
This script is :copyright:2023 by Christopher Allen, and is licensed under the
[spdx:BSD-2-Clause Plus Patent License](https://spdx.org/licenses/BSD-2-Clause-Patent.html)
*)
tell application "System Events"
set activeApps to name of application processes whose frontmost is true
set activeApp to item 1 of activeApps
end tell
tell application activeApp
activate
reopen
end tell
tell application "System Events"
tell process activeApp
set the position of front window to {0, 38}
set the size of front window to {1280, 720 - 38}
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment