Created
February 26, 2010 20:59
-
-
Save cowboy/316149 to your computer and use it in GitHub Desktop.
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
(* | |
* Safari Resize Full x Full - v1.0 - 2/26/2010 | |
* http://benalman.com/ | |
* | |
* Copyright (c) 2010 "Cowboy" Ben Alman | |
* Dual licensed under the MIT and GPL licenses. | |
* http://benalman.com/about/license/ | |
*) | |
set minX to 0 | |
set minY to 22 | |
tell application "Finder" to set screen_resolution to items 3 thru 4 of (get bounds of desktop's window) | |
set maxX to item 1 of screen_resolution | |
set maxY to item 1 of screen_resolution | |
--set maxX to (do shell script "echo $(defaults read /Library/Preferences/com.apple.windowserver) | sed 's/.*Width = \\([0-9]*\\);.*/\\1/'") as number | |
--set maxY to ((do shell script "echo $(defaults read /Library/Preferences/com.apple.windowserver) | sed 's/.*Height = \\([0-9]*\\);.*/\\1/'") as number) - 4 | |
-- Modify as necessary: | |
set width to maxX --1024 | |
set myBounds to {maxX - width, minY, maxX, maxY} | |
--tell application "System Events" to set frontApp to title of (first process whose frontmost is true) | |
set frontApp to "Safari" | |
tell application frontApp | |
try | |
set allWindows to (every document) | |
if (the (count of allWindows) = 0) then | |
set defaultPage to do shell script "defaults read com.apple.internetconfig | egrep '^ *WWWHomePage' | sed 's/^.*\" = \"\\(.*\\)\".*$/\\1/'" | |
make new document with properties {URL:defaultPage} | |
else | |
reopen | |
end if | |
set the bounds of front window to myBounds | |
activate | |
end try | |
end tell |
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
(* | |
* Safari Resize / Move By - v1.0 - 2/26/2010 | |
* http://benalman.com/ | |
* | |
* Copyright (c) 2010 "Cowboy" Ben Alman | |
* Dual licensed under the MIT and GPL licenses. | |
* http://benalman.com/about/license/ | |
*) | |
-- Modify these as necessary: | |
set resizeXby to 100 | |
set resizeYby to 0 | |
set moveXby to 0 | |
set moveYby to 0 | |
-- get screen dimensions | |
tell application "Finder" to set ScreenBounds to the bounds of desktop's window | |
set ScreenMinX to item 1 of ScreenBounds | |
set ScreenMinY to item 2 of ScreenBounds | |
set ScreenMaxX to item 3 of ScreenBounds | |
set ScreenMaxY to item 4 of ScreenBounds | |
set ScreenMinY to 22 -- override for height of os x menu bar | |
--tell application "System Events" to set frontApp to title of (first process whose frontmost is true) | |
set frontApp to "Safari" | |
tell application frontApp | |
try | |
set WindowBounds to the bounds of front window | |
set WindowMinX to (item 1 of WindowBounds) + moveXby | |
set WindowMinY to (item 2 of WindowBounds) + moveYby | |
set WindowMaxX to (item 3 of WindowBounds) + resizeXby | |
set WindowMaxY to (item 4 of WindowBounds) + resizeYby | |
if (WindowMaxX > ScreenMaxX) then | |
set WindowMinX to WindowMinX - (WindowMaxX - ScreenMaxX) | |
set WindowMaxX to ScreenMaxX | |
end if | |
if (WindowMaxY > ScreenMaxY) then | |
set WindowMinY to WindowMinY - (WindowMaxY - ScreenMaxY) | |
set WindowMaxY to ScreenMaxY | |
end if | |
if (WindowMinX < ScreenMinX) then | |
set WindowMaxX to (WindowMaxX - WindowMinX) | |
set WindowMinX to ScreenMinX | |
if (WindowMaxX > ScreenMaxX) then | |
set WindowMaxX to ScreenMaxX | |
end if | |
end if | |
if (WindowMinY < ScreenMinY) then | |
set WindowMaxY to (WindowMaxY - WindowMinY) | |
set WindowMinY to ScreenMinY | |
if (WindowMaxY > ScreenMaxY) then | |
set WindowMaxY to ScreenMaxY | |
end if | |
end if | |
set the bounds of front window to {WindowMinX, WindowMinY, WindowMaxX, WindowMaxY} | |
activate | |
end try | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment