Firefox gather windows script for dual monitor annoyance!

Oct 29, 2010 01:58

New Firefox windows opening on your second monitor? Second monitor off or in use for something else? I found a script and tweaked it slightly for my tastes to gather only firefox windows on the first display, and it woks beautifully. Original script posted and tweaked a few times HERE.

My final version

______________________________________

property processToInclude : {"Firefox"}

tell application "Finder"
    set _b to bounds of window of desktop
    set screen_width to 1680 - 1
    set screen_height to 1050
end tell

tell application "System Events"
    set allProcesses to application processes
    set _results to ""
    repeat with i from 1 to count allProcesses
        set doIt to 1
        repeat with z from 1 to count processToInclude
            if process i is not equal to process (item z of processToInclude) then
                set doIt to 0
            end if
        end repeat
        if doIt = 1 then
            tell process i
                -- Let's make this guarantee that windows off to the right side are brought
                -- entirely on-screen.
                --
                -- This solves an issue when switching from an internal main display
                -- to an external one where windows are often at the farthest right
                -- edge of the screen and you have to grab them near the close button
                repeat with x from 1 to (count windows)
                    set winPos to position of window x
                    set _x to item 1 of winPos
                    set _y to item 2 of winPos
                    set winSize to size of window x
                    set _w to item 1 of winSize
                    if (_x < 0 or _y < 0) then
                        set position of window x to {0, 80}
                    else if ((_x + _w) > screen_width or _y > screen_height) then
                        set position of window x to {screen_width - _w, 80}
                    end if
                end repeat
            end tell
        end if
    end repeat
end tell

tech

Previous post Next post
Up