Make a window follow another window


I’m working on an application that acts as an overlay for another application. I got some stuff to work but the thing is that I’d like the overlay to follow the original window. Also I got this partially working. I’m using this method:

on idle theObject
	tell application "[App name]"
		set a to bounds of window 1 of application "[App name]"
	end tell

	tell window 1
		set bounds to a
	end tell
end idle

This kind of works except that movement on the x-axis is followed nicely but the y-axis is inverted. I’m probably overlooking something but I can’t figure out what. Does this ring a bell to anyone? And while we’re on the subject, is this a good way to do this without much hassle or are there better options? Thanks in advance for all your help.


When you get the bounds of the app, the origin is upper left. Setting the bounds in AS Studio uses the lower left as its origin. When you get the bounds of the app, switch the coordinates around.

{x1, y1, x2, y2}


{x1, y2, x2, y1

Editted: wait, I think I made a mistake. :slight_smile: I think you have to subtract it from the screen bounds.