Get current window position

The position of a Dialog Toolkit Plus window can be set with the initial position parameter. I would like to get the position of the window just before it is closed eg. because the user has moved it. It would then be possible to use that position for the initial position when the window is opened again.

Is it possible to get the position of a DTP window from controlResults ?

Thanks.

You’ll have edit the script. Add a property called finalPosition. Then before the -- close window line in showTheWindowAndWaitMainThread:, add this:

	set windowFrame to theWindow's frame()
	set theLeft to current application's NSMinX(windowFrame)
	set theBottom to current application's NSMinY(windowFrame)
	set theHeight to current application's NSHeight(windowFrame)
	set screenFrame to NSScreen's mainScreen()'s frame()
	set screenHeight to current application's NSHeight(screenFrame)
	set theTop to screenHeight - theHeight - theBottom
	set my finalPosition to {theLeft, theTop}

Finally, change the display enhanced window handler so it returns {buttonName, controlResults, finalPosition}.

That’s untested, but it should at least get you close.

Many thanks. This works perfectly.

Cheers.