safari windows

I can’t seem to get safari to position and resize windows. I tried Javascript and setting window position, but I can’t get it to work. I have a chat site that I’d like to open on launch, but in a small window on my second monitor (w 482, h 351@x1569 y374); afterwards, I want to launch a new window with my homepage (Google). I can’t even get the first part to work though. I am trying to look at the sample scripts from Apple, but merely changing the variables from the full window scripts doesn’t seem to do the trick.

Also, is there a way to return the window focus to the Safari window after executing a script from the script menu? I keep having to click on the browser window before I can return to scrolling or typing.

Safari supports Javascript. For resizing windows I keep one in my “BookMarks Bar” to maximize the size of a Safari window to fit my screens full size…

javascript:self.moveTo(10,20);self.resizeTo(screen.availWidth-12,screen.availHeight-0)

I find this to be the quickest and best solution for managing Safari window sizes. You could create a folder of different sizing schemes to suit your needs.

Here some code I use to place my Downloads window:


tell application "Safari"
	activate
	try
		set bounds of every window whose name is "Downloads" to {715, 640, 978, 768}
	end try
end tell

I hope this helps.

That is an annoying thing with Apples ScriptMenu. There is a Shareware called Fastscripts that returns to the previous active App after executing the Script (http://www.red-sweater.com/RedSweater/FastScripts.html), or my favourite iKey, that does a lot more (Script Software)

Have Fun!

starbuck, I would love to see a way of making the downloads window ‘poof’ (aka go away) after a download has completed. Ya got any tricks? Also, I do agree that Apple’s Script Menu is a bit lacking but it is handy if you learn some of it’s tricks.

I got the moving to work, it wasn’t much of a code problem (though I did have to relaunch Safari after some nonresponsive misbehavior). The code was more or less like the full screen examples I found on the web. After tinkering for a while, I found the problem to be with multiple monitors. When the script is run, the windows are launched in the monitor where the last window was active. How can I set and change which monitor I am dealing with? I’m trying to sort through the Applescript Stuido Ref Guide for a clue, but there’s a mess of info in the documentation, and my eyes are starting to burn after a few hours of screen reading. I wish these .pdfs supported inline links…