Created
June 15, 2016 22:53
-
-
Save Jahhein/b0560740b3d9a25e523ee4fc142ba09b to your computer and use it in GitHub Desktop.
Applescript 2x2 finder
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
property pWindowWidth : 975 | |
property pWindowHeight : 440 | |
property pWindowChromeHeight : 23 | |
property pDockPadding : 1 | |
on run | |
tell application "Finder" | |
close every window | |
my positionWindow(my makeWindow("/Users/mjt/"), 2) | |
my positionWindow(my makeWindow("/Users/mjt/Downloads/"), 1) | |
end tell | |
end run | |
on makeWindow(_path) | |
set _file to POSIX file _path | |
tell application "Finder" | |
set _window to make new Finder window | |
set _container to container file | |
set _window's target to _container | |
set _window's bounds to {0, 0, pWindowWidth, pWindowHeight} | |
set _window's current view to column view | |
set _window's toolbar visible to true | |
set _window's sidebar width to 160 | |
set _window's statusbar visible to true | |
set _window's statusbar visible to false | |
set _window's statusbar visible to true | |
return _window | |
end tell | |
end makeWindow | |
on positionWindow(_window, _levelFromBottom) | |
tell application "Finder" | |
set {_left, _top, _right, _bottom} to bounds of desktop's window | |
set _x to _right - pWindowWidth - pDockPadding - (my dockWidth()) | |
set _fullWindowHeight to pWindowHeight + pWindowChromeHeight | |
set _y to _bottom - _fullWindowHeight * _levelFromBottom + pWindowChromeHeight | |
if (system attribute "sys2") ≥ 11 then -- In El Capitan, Finder now counts title bar in window size | |
set _fullWindowHeight to _fullWindowHeight - pWindowChromeHeight | |
set _y to _y + (_levelFromBottom - 1) * pWindowChromeHeight | |
end if | |
set _window's position to {_x, _y} | |
end tell | |
end positionWindow | |
on dockWidth() | |
tell application "System Events" | |
tell application process "Dock" | |
set {_width, _height} to size of list 1 | |
return _width | |
end tell | |
end tell | |
end dockWidth |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment