Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 3, 2009, 02:46 PM   #1
cintari
macrumors newbie
 
Join Date: Mar 2007
WinSplit for OSX

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
cintari is offline   0 Reply With Quote
Old Feb 3, 2009, 04:09 PM   #2
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
I don't think there is a "perfect" way to do this in AppleScript (there are APIs in other languages though) but parts of these scripts might help:
http://blog.slaunchaman.com/tag/applescript/
http://www.macosxhints.com/article.p...70617075008161

Last edited by kainjow; Feb 3, 2009 at 04:50 PM.
kainjow is offline   0 Reply With Quote
Old Feb 3, 2009, 04:33 PM   #3
cintari
Thread Starter
macrumors newbie
 
Join Date: Mar 2007
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.
cintari is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
help! iv turned my ssd drive (all of it) to OSX Base System and i cant reinstall osx nemotheswimmer OS X Mavericks (10.9) 4 Apr 2, 2014 02:26 PM
Osx 10.9.1 Mein OS X Mavericks (10.9) 2 Feb 18, 2014 07:35 AM
new to osx kelvinguy85 MacBook Pro 2 Oct 8, 2013 07:35 PM
OSX 10.5.8 Backup For New OSX JonnyAlpha Mac Applications and Mac App Store 9 Dec 2, 2012 11:08 AM
Problems with OSX restoring OSX Yogakun OS X 2 Nov 19, 2012 11:33 PM

Forum Jump

All times are GMT -5. The time now is 07:36 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC