-
-
Save confluencepoint/87eb52090e144ee1cb11b3a44e4c3cd1 to your computer and use it in GitHub Desktop.
An Applescript to resize windows from the command line
This file contains hidden or 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
on run argv | |
-- Variables | |
set _cmd to (item 1 of argv) | |
tell application "Finder" to set _bounds to bounds of window of desktop | |
set _xPos to (item 1 of _bounds) | |
set _yPos to (item 2 of _bounds) | |
set _ySize to (item 3 of _bounds) | |
set _xSize to (item 4 of _bounds) | |
-- get bounds | |
-- do split: app1, app2, set split | |
if (_cmd = "split") then | |
set _app1 to (item 2 of argv) | |
set _app2 to (item 3 of argv) | |
set _splitPerc to ((item 4 of argv)/100) | |
set _splitPoint to (_ySize*_splitPerc) | |
tell application "System Events" to tell process _app1 | |
set position of front window to {_xPos, _yPos} | |
set size of front window to {_splitPoint, _xSize} | |
end tell | |
tell application "System Events" to tell process _app2 | |
set position of front window to {_splitPoint, _yPos} | |
set size of front window to {_ySize-_splitPoint, _xSize} | |
end tell | |
if (_splitPerc >= 0.5) then | |
--your code | |
tell application _app2 to activate | |
tell application _app1 to activate | |
else | |
--your code | |
tell application _app1 to activate | |
tell application _app2 to activate | |
end if | |
end if | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment