Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Non-GUI approach (shorter too)' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Non-GUI approach (shorter too)
Authored by: christianboyce on Jul 23, '04 10:14:00PM
The "click menu item" steps in your script require the user to have GUI scripting turned on (System Preferences, Universal Access, Enable access for assistive devices). That's not the way Macs are set up out of the box. Better not to rely on the user's machine being set up a certain way. Generally speaking, try to avoid GUI scripting except as a last resort.

Here is a general script that opens Safari windows and fills them in with various sites, taken from a list. I like the sites being in their own windows because I occasionally make the mistake of clicking a close button in a Safari window that has tabs, closing who knows how many tabbed sites with it.

It's nice to be able to resize the windows via JavaScript-- very fast. Of course, this depends on JavaScript being available, but this is the default for Safari.


tell application "Safari"
	--add your sites to this list, in quotes
	set thelist to {"http://www.apple.com", "http://www.christianboyce.com", "http://www.macosxhints.com"}
	--no matter how many sites you've listed, the repeat will work properly
	repeat with thesite in thelist
		set y to make new document at beginning
		set the URL of the front document to thesite
	end repeat
	--if you're in the mood for a little javascript you can resize and reposition each window to full screen in a hurry
	repeat with i from 1 to the count of documents
		do JavaScript "moveTo(0,0);self.resizeTo(screen.availWidth,screen.availHeight)" in document i
	end repeat
	--javascript courtesy of Apple's website, www.apple.com/applescript
end tell


[ Reply to This | # ]