Last active
November 3, 2022 06:34
-
-
Save ChristoferK/990c63e831fbf09f6ef792a3a0b92e38 to your computer and use it in GitHub Desktop.
[Centre Window on Screen] Centres the frontmost window on screen #AppleScript #SystemEvents #UI #window #position
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use application "System Events" | |
property process : a reference to (first process whose frontmost = true) | |
property window : a reference to front window of my process | |
property display : a reference to scroll area 1 of process "Finder" | |
if not (my window exists) then return | |
set [width, height] to size of my window | |
set [screenX, screenY] to size of my display | |
set position of my window to [(screenX - width) / 2, (screenY - height) / 2] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment