Simple Window Handling for Dual monitors under Mavericks

Hello.

Below are some scripts I have mocked togheter for rudimentary screen handling. I assume that your monitors are set up to the same resolution, and that you haven’t skewed them (no overlap).

I can’t make them work as applets, so you better have some spare shortcuts in Fastscripts or whatever you use for running scripts from hotkeys.

Teleport, moves the front window to the other screen.

tell application id "MACS" to set {x1, tmpvar, x2, tmpvar} to bounds of window of desktop
tell application id "sevs"
	tell first window of (first application process whose frontmost is true and visible is true)
		set {oldx, oldy} to its position
		if oldx > ((x1 + x2) / 2) then
			if x1 < 0 then
				set newx to oldx + x1
			else
				set newx to oldx - x1
			end if
		else
			if x1 < 0 then
				set newx to oldx - x1
			else
				set newx to oldx + x1
			end if
		end if
		set its position to {newx, oldy}
	end tell
end tell

Right moves the frontmost window to the right edge of the current screen.

tell application id "MACS" to set {x1, tmpVar, x2, tmpVar} to bounds of window of desktop
tell application id "sevs"
	tell first window of (first application process whose frontmost is true and visible is true)
		set {{oldx, oldy}, {wwidth, tmpVar}, startRDsp} to {its position, its size, ((x1 + x2) / 2)}
		-- Is it on the right screen?
		if oldx ≥ startRDsp then
			set newx to x2 - wwidth
		else
			-- or on the left screen?
			set newx to startRDsp - wwidth
		end if
		set its position to {newx, oldy}
	end tell
end tell

Left moves the frontmost window to the left edge of the screen.

tell application id "MACS" to set {x1, tmpVar, x2, tmpVar} to bounds of window of desktop
tell application id "sevs"
	tell first window of (first application process whose frontmost is true and visible is true)
		set {{oldx, oldy}, {wwidth, tmpVar}, startRDsp} to {its position, its size, ((x1 + x2) / 2)}
		-- Is it on the right screen?
		if oldx ≥ startRDsp then
			set newx to startRDsp
		else
			-- or on the left screen?
			set newx to x1
		end if
		set its position to {newx, oldy}
	end tell
end tell

Up moves the frontmost window to the top of the screen.

tell application id "sevs"
	tell first window of (first application process whose frontmost is true and visible is true)
		set {oldx, tmpVar} to its position
		set newY to 22
		set its position to {oldx, newY}
	end tell
end tell

Down moves the frontmost window to the bottom edge of the screen.

tell application id "MACS" to set {tmpVar, tmpVar, tmpVar, y2} to bounds of window of desktop
tell application id "sevs"
	tell first window of (first application process whose frontmost is true and visible is true)
		set {{oldx, tmpVar}, {tmpVar, wheight}} to {its position, its size}
		set newY to y2 - wheight
		set its position to {oldx, newY}
	end tell
end tell