Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Some improvements' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Some improvements
Authored by: parki3n on Sep 14, '08 08:24:52PM

I found this script very useful, but I ended up making a few improvements that I wanted to share:

1. I wanted it to maximize both vertically and horizontally.
2. I wanted it to figure out the size of the screen programatically, instead of being hard coded.
3. I also wanted it to take into account the dock size automatically.

Some of the code for this was pulled together from other sites on the web, but it's all documented in the Applescript library help.

tell application "Finder"
     set _b to bounds of window of desktop
     set _display_x_size to (item 3 of _b)
     set _display_y_size to (item 4 of _b)
end tell

set cur_app to (path to frontmost application as Unicode text)
if cur_app ends with ":Finder.app:" then
     set Finder to true
     tell application "Finder"
          set tool_vis to toolbar visible of front window
     end tell
else
     set Finder to false
end if

tell application cur_app
     tell front window
          set {x1, y1, x2, y2} to (get bounds)
          set y1 to 44 (* To account for the toolbar *)
          set x1 to 0
          set x2 to _display_x_size
          if Finder then
               -- FINDER (Finder application returns a strange value, so this gets the correct info)
               if tool_vis then
                    -- This section retrieves the vertical height of the Dock
                    tell application "System Events" to tell process "Dock"
                         set _dock_dimensions to size in list 1
                         set _dock_height to item 2 of _dock_dimensions
                    end tell
                    set y2 to (_display_y_size - _dock_height)
                    --set y2 to _display_y_size
                    -- OLD: set y1 to 83
               else
                    set y2 to _display_y_size
               end if
          else
               -- NOT FINDER
               set y2 to _display_y_size
          end if
          set bounds to {x1, y1, x2, y2}
     end tell
end tell




[ Reply to This | # ]