Getting a window to remember it's position.

Hey guys, I was wondering if someone could point me in the right direction on getting my window to remember it’s position between launches of the application. The code I’m using to save the bounds of the window when the app quits is this at the moment:

on will quit theObject
	(*Add your script here.*)
	do shell script "defaults write com.tomhennigan.ituneshover bounds " & (bounds of window "mainWindow")
end will quit

Then when the app is launched I execute this:

on awake from nib theObject
	(*Add your script here.*)
	try
		set bounds of window "mainWindow" to (do shell script "defaults read com.tomhennigan.ituneshover bounds")
	on error
		center window "mainWindow"
	end try
	show (window of theObject)
end awake from nib

Sadly this doesn’t work :(. I had a look at what the first command saved and it was:
7040102398
So I’m guessing the bounds are actually:
70 40 102 398
Any one got any ideas on how I can actually get the bounds into a list like {70,40,102,398}?
All help appreciated!

This is actually WAAAY easier than you’re making it. :cool:

In interface builder, in the general info pane, simply provide an autosave name for the window. Right beneath the text field for the window’s title is the ‘autosave name’ field. Just give it a unique name and it will handle the positioning automatically for you… no programming overhead required.

j

:smiley: Thanks jobu you saved me a lot of time!!