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


Click here to return to the 'Open new Safari window with an AppleScript application' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Open new Safari window with an AppleScript application
Authored by: joeholmes on Dec 10, '03 11:26:54AM
This is really great, but I'd love to add one more wrinkle to the script.

What I hate is switching to Safari and then having to open a new window before I can type any URL etc. What I want is a script that will create a new Safari window only if no window is open.

I'm sure a simple "if" statement will do the trick, but I can't find a way to tell Applescript to detect a window in Safari.

Anyone?

-=-Joe

[ Reply to This | # ]

Open new Safari window with an AppleScript application
Authored by: ChaChi on Dec 10, '03 11:50:23AM

Try this:

tell application "Safari"
if windows is {} then reopen
end tell

Hope this helps...



[ Reply to This | # ]
Open new Safari window with an AppleScript application
Authored by: joeholmes on Dec 10, '03 10:34:25PM
Perfect ...thanks! I've set it to trigger with Keyboard Maestro, so now my F-key of choice switches to Safari and makes sure at least one window is open.

[ Reply to This | # ]
Open new Safari window with an AppleScript application
Authored by: larkost on Dec 10, '03 12:01:58PM
Oohhh.. fun AppleScript for a change!

set aWindowIsOpen to false
tell application "Safari"
	repeat with thisWindow in windows
		if (not miniaturized of thisWindow) then
			set aWindowIsOpen to true
		end if
	end repeat
	
	if (aWindowIsOpen) then
		activate
	else
		make new document with properties {URL:"http://www.macosxhints.com"}
	end if
end tell
Clicking on this script should do what you want.

[ Reply to This | # ]