Created
April 24, 2018 18:36
-
-
Save kassadin/e378628b4645ac2ada32cc5c0cdafb3b to your computer and use it in GitHub Desktop.
osx resize window, but how to run it without the editor?
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
-- set screenWidth to (do shell script "system_profiler SPDisplaysDataType | awk '/Resolution/{print $2}'") | |
-- set screenHeight to (do shell script "system_profiler SPDisplaysDataType | awk '/Resolution/{print $4}'") | |
on run argv | |
set {width, height, scale} to words of (do shell script "system_profiler SPDisplaysDataType | awk '/Built-In: Yes/{found=1} /Resolution/{width=$2; height=$4} /Retina/{scale=($2 == \"Yes\" ? 2 : 1)} /^ {8}[^ ]+/{if(found) {exit}; scale=1} END{printf \"%d %d %d\\n\", width, height, scale}'") | |
log width | |
log height | |
log scale | |
-- to the left top | |
set p to {0, 0} | |
set s to {width / 2, height / 2} | |
tell application "System Events" | |
set currentApp to name of the first process whose frontmost is true | |
tell process currentApp | |
tell window 1 | |
set w1 to name of it | |
log w1 | |
set position to p | |
set size to s | |
end tell | |
end tell | |
end tell | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Python rumps can display a tray menu, then it can control the size and position of the frontmost window, Such as LeftTop、Left...But now the script can't run without the editor.
Maybe I should try swift.