WinSplit for OSX

Discussion in 'Mac Programming' started by cintari, Feb 3, 2009.

  1. macrumors newbie

    Joined:
    Mar 1, 2007
    Messages:
    21
    #1
    Hey,

    I use Winspit Revolution on windows and it is great. I couldn't find an equivalent for Mac so I wrote up some applescripts to copy the functionality. I bound these scripts to quicksilver triggers and it works great.

    Code:
    on run
    	
    	tell application "Finder"
    		set {disp_x1, disp_y1, disp_x2, disp_y2} to bounds of window of desktop
    	end tell
    	
    	tell application "System Events"
    		set frontmostApplication to name of the first process whose frontmost is true
    		set {menuBarWidth, menuBarHeight} to size of UI element 1 of application process "SystemUIServer"
    		tell process frontmostApplication
    			set {x1, y1} to position of front window
    			set {x2, y2} to size of front window
    			tell front window
    				set position to {x1, (disp_y2 + menuBarHeight) / 2}
    				set size to {x2, (disp_y2 - menuBarHeight) / 2}
    			end tell
    		end tell
    	end tell
    	
    end run
    
    This code is largely taken from http://blog.insidesystems.net/articles/category/os-x

    So this script is specifically for docking to the bottom.

    How do I make this generic so I dont have to copy this code for each dock (left, right, up, down)?

    Thanks
     
  2. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    Messages:
    7,743
    #2
  3. macrumors newbie

    Joined:
    Mar 1, 2007
    Messages:
    21
    #3
    This works fine for me. The issue I'm having is that i need 4 separate scripts (up, left, right, down) for each trigger.

    It would be easier to maintain if each script could just say:

    sizeWindow(pos, size)

    where sizeWindow is defined in a separate script file.

    Is there a way to do this? I can't seem to find out how to include a file or make a library.
     

Share This Page