hayesk
Apr 30th, 2010, 05:56 PM
So, as I watched a WIndows 7 ad showing the Snap feature, I thought to myself, why wouldn't I just tile the windows or arrange them myself? Turns out, it's a bit cumbersome to do - well, the right window. So I thought I'd make one myself. Here's how:
First, open AppleScript Editor and go to the Preferences. Enable the AppleScript menu in the menu bar. From there choose "Open Scripts Folder > Open Computer Scripts Folder" from that menu (it's a little script icon on the right side of the menu bar) - this is where you'll save the scripts.
Then paste the following code:
tell application "Finder"
set screenBounds to bounds of window of desktop
set frontmostApplication to name of the first process whose frontmost is true
end tell
set screenWidth to item 3 of screenBounds
set screenHeight to item 4 of screenBounds
tell application frontmostApplication
--display dialog frontmostApplication as string
set myWindows to windows whose visible is true
get bounds of item 1 of myWindows
-- left
set bounds of item 1 of myWindows to {1, 22, screenWidth / 2, screenHeight - 60}
-- right
-- set bounds of window 1 to {screenWidth / 2, 22, screenWidth + 1, screenHeight - 60}
end tell
Save this as "snap window left" in that window you opened.
Then remove the -- from the line below the --right line, and add -- to the line below --left
Save as "snap window right" in that window you opened. Now, when you choose one of those commands from the Scripts menu, it will act on the frontmost window.
You can enhance it a little too. You could save them as Application Bundles and put them in your dock. You may be able to assign Keyboard shortcuts to them using the Keyboard preferences too.
Also, I hard-coded 60 as my Dock height - you may need to change it for yours, especially if you have your dock on the side. The order of the dimensions are {left, top, right, bottom}
Hope you like.
First, open AppleScript Editor and go to the Preferences. Enable the AppleScript menu in the menu bar. From there choose "Open Scripts Folder > Open Computer Scripts Folder" from that menu (it's a little script icon on the right side of the menu bar) - this is where you'll save the scripts.
Then paste the following code:
tell application "Finder"
set screenBounds to bounds of window of desktop
set frontmostApplication to name of the first process whose frontmost is true
end tell
set screenWidth to item 3 of screenBounds
set screenHeight to item 4 of screenBounds
tell application frontmostApplication
--display dialog frontmostApplication as string
set myWindows to windows whose visible is true
get bounds of item 1 of myWindows
-- left
set bounds of item 1 of myWindows to {1, 22, screenWidth / 2, screenHeight - 60}
-- right
-- set bounds of window 1 to {screenWidth / 2, 22, screenWidth + 1, screenHeight - 60}
end tell
Save this as "snap window left" in that window you opened.
Then remove the -- from the line below the --right line, and add -- to the line below --left
Save as "snap window right" in that window you opened. Now, when you choose one of those commands from the Scripts menu, it will act on the frontmost window.
You can enhance it a little too. You could save them as Application Bundles and put them in your dock. You may be able to assign Keyboard shortcuts to them using the Keyboard preferences too.
Also, I hard-coded 60 as my Dock height - you may need to change it for yours, especially if you have your dock on the side. The order of the dimensions are {left, top, right, bottom}
Hope you like.