forked from wycats/osx-window-sizing
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4380a60
Showing
4 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
OSX Window Sizing | ||
================= | ||
|
||
OSX Window Sizing is a set of apps that makes it dead-simple to change the size of | ||
you windows. At present, it comes with two apps: center and maximize | ||
|
||
maximize | ||
-------- | ||
|
||
Maximize will maximize your windows to full-screen. It will take drawers into consideration | ||
as well, so applications like TextMate will truly fill the screen. This works even in | ||
applications with Zoom buttons that don't truly maximize (like Safari). | ||
|
||
center | ||
------ | ||
|
||
Center will ask you for a pixel size (e.g. "1024x768") and resize your application window | ||
to that size. It will then center the application on the screen. It defaults to 800x600. | ||
|
||
Installation | ||
------------ | ||
|
||
Install the scripts by typing `rake install` in this directory. This will compile the | ||
applescripts into .scpt files and copy them into your ~/Library/Scripts folder. | ||
|
||
Usage | ||
----- | ||
|
||
It is recommended that you bind the scripts to shortcut keys in the system. I personally | ||
use `ctrl-shift-M` for maximize and `ctrl-shift-C` for center. | ||
|
||
Running `rake install_fastscripts` will download a free app called FastScripts Lite, | ||
mount it, and open the mounted folder so you can complete the installation. This will | ||
provide a menu-bar replacement for the `Scripts` menubar that will allow you to attach | ||
keys to any script. | ||
|
||
OSX Window Sizing will only work if the window in question is the front-most window | ||
(future versions might provide support for choosing the window or windows you wish | ||
to resize). |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
desc "Compile scripts to .scpt files" | ||
task :compile do | ||
puts "Compiling center.applescript..." | ||
system "osacompile -o center.scpt center.applescript" | ||
puts "Compiling center.applescript..." | ||
system "osacompile -o maximize.scpt maximize.applescript" | ||
puts "Done" | ||
puts | ||
end | ||
|
||
desc "Install scripts to your scripts folder" | ||
task :install => :compile do | ||
puts "Copying scripts to your scripts folder" | ||
system "cp *.scpt ~/Library/Scripts" | ||
puts "Done" | ||
puts | ||
end | ||
|
||
desc "Download and mount FastScripts" | ||
task :install_fastscripts do | ||
system "curl http://www.red-sweater.com/fastscripts/FastScriptsLite2.3.6.dmg > FastScripts.dmg" | ||
system "hdiutil attach FastScripts.dmg" | ||
puts "FastScripts Lite is now mounted in your system. Opening the folder..." | ||
sleep 1 | ||
system "open \"/Volumes/FastScripts Lite 2.3.6\"" | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
set windowWidth to 800 | ||
set windowHeight to 600 | ||
delay 0.1 | ||
|
||
set AppleScript's text item delimiters to "x" | ||
|
||
set res to text returned of (display dialog "Enter the width x height:" default answer ((windowWidth & windowHeight) as text)) | ||
|
||
if res is "" then | ||
display dialog "You need to enter a correct response" | ||
return | ||
end if | ||
set {windowWidth, windowHeight} to text items of res | ||
|
||
set AppleScript's text item delimiters to "" | ||
|
||
tell application "Safari" | ||
set screen_width to (do JavaScript "screen.availWidth" in document 1) | ||
set screen_height to (do JavaScript "screen.availHeight" in document 1) | ||
end tell | ||
|
||
tell application "System Events" | ||
set myFrontMost to name of first item of (processes whose frontmost is true) | ||
end tell | ||
|
||
tell application "Finder" | ||
set {desktopTop, desktopLeft, desktopRight, desktopBottom} to bounds of desktop | ||
end tell | ||
|
||
try | ||
tell application "System Events" | ||
tell process myFrontMost | ||
set {{w, h}} to size of drawer of window 1 | ||
end tell | ||
end tell | ||
on error | ||
set {w, h} to {0, 0} | ||
end try | ||
|
||
tell application "System Events" | ||
tell process myFrontMost | ||
try | ||
set {{w, h}} to size of drawer of window 1 | ||
on error | ||
set {w, h} to {0, 0} | ||
end try | ||
set position of window 1 to {((screen_width - windowWidth - w) / 2), ((screen_height - windowHeight) / 2.0) - desktopTop} | ||
set size of window 1 to {windowWidth, windowHeight} | ||
end tell | ||
end tell |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
tell application "Safari" | ||
set screen_width to (do JavaScript "screen.availWidth" in document 1) | ||
set screen_height to (do JavaScript "screen.availHeight" in document 1) | ||
end tell | ||
|
||
tell application "System Events" | ||
set myFrontMost to name of first item of (processes whose frontmost is true) | ||
end tell | ||
|
||
tell application "Finder" | ||
set {desktopTop, desktopLeft, desktopRight, desktopBottom} to bounds of desktop | ||
end tell | ||
|
||
try | ||
tell application "System Events" | ||
tell process myFrontMost | ||
set {{w, h}} to size of drawer of window 1 | ||
end tell | ||
end tell | ||
on error | ||
set {w, h} to {0, 0} | ||
end try | ||
|
||
tell application "System Events" | ||
tell process myFrontMost | ||
try | ||
set {{w, h}} to size of drawer of window 1 | ||
on error | ||
set {w, h} to {0, 0} | ||
end try | ||
set position of window 1 to {0, 0} | ||
set size of window 1 to {screen_width - w, screen_height} | ||
end tell | ||
end tell |