Maximizing windows in OS X

So my mouse was acting crazy, and basically it caused me to shrink a window down to like 2x10 pixels... impossible to drag back to maximum size. After some research, I found an AppleScript that can be used to maximize windows:
tell application "System Events"
if UI elements enabled then
set FrontApplication to (get name of every process whose frontmost is true) as string
tell process FrontApplication
click button 2 of window 1
--button 2 is the green "zoom" button for all applications
--window 1 is always the frontmost window.
end tell
else
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.universalaccess"
display dialog "UI element scripting is not enabled. Check 'Enable access for assistive devices'"
end tell
end if
end tell

I then downloaded QuickSilver (by blacktree), and bound the script to the keys COMMAND+Z. Now I can just select any window, hit COMMAND+Z, and the window will maximize again. WHEW! What a life-saver.

To add the script to QS, you do the following:
1. Goto the Triggers tab
2. Hit the small + icon at the bottom left
3. Select (add) hotkey
4. Click on the Command-Key column, and set your Hot Key
5. Double-click on the Command column
6. For Select an Item, select the apple-script you just created
7. The Action should automatically be 'Run'
8. Save and exit

Test out your script by pressing the hotkey... it worked for me :)

No comments: