Re: AppleScript-Users Digest, Vol 6, Issue 324
Re: AppleScript-Users Digest, Vol 6, Issue 324
- Subject: Re: AppleScript-Users Digest, Vol 6, Issue 324
- From: Cezary Okupski <email@hidden>
- Date: Thu, 16 Jul 2009 18:37:03 +0000
I am struck with simple script.
I am opening Safari on Leapord using script as following:
tell application "Safari"
activate
--open some url
end tell
Its working fine. But the problem is that if Safari is already
opened and showing some webpage, its over writing in same window/tab
of Safari.
What I want is that if Safari is already running, I want to create a
new tab and open url in that. If Safari is not running, I just want
to launch it and open the URL in first window (not in a new tab).
Looking for some help here.
on openURI(URI)
if (count (windows of application "Safari" whose visible is true)) is
greater than 0 then
using terms from application "Safari"
-- in the following condition URL check is not enough as a page
that is currently loading may have URL empty; on the other hand name
check alone may have false positives too
-- update the second condition with a translation of "Untitled" for
your system language if necessary
if URL of current tab of front window of application "Safari" as
text is "" and name of current tab of front window of application
"Safari" is in {"Untitled", "bez tytułu"} or URL of current tab of
front window of application "Safari" as text is "topsites://" then
set URL of current tab of front window of application "Safari" to
URI
set myTab to a reference to current tab of front window of
application "Safari"
else
tell front window of application "Safari" to set myTab to a
reference to make new tab with properties {URL:URI}
set current tab of front window of application "Safari" to myTab
end if
end using terms from
else
using terms from application "Safari"
tell application "Safari" to make new document with properties
{URL:URI}
set myTab to a reference to current tab of front window of
application "Safari"
end using terms from
end if
return myTab
end openURI
--
Best regards
Cezary Okupski _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden