Re: Closing Safari Tab...
Re: Closing Safari Tab...
- Subject: Re: Closing Safari Tab...
- From: Nigel Garvey <email@hidden>
- Date: Sun, 11 Dec 2011 15:03:58 +0000
David Crowe wrote on Sat, 10 Dec 2011 11:42:13 -1000:
>I am having difficulty closing tabs in a Safari window with multiple
tabs.
>
>Take this for example:
>
>tell application "Safari" to tell window 1
> close tab 1
>end tell
>
>Can't get much simpler than that, but while it sometimes works I
>usually get: "Safari got an error: NSInternalScriptError".
>
>The last time I ran it it worked the first time and then consistently
>failed.
>
>What I'd really like to do is close all tabs other than the current
>one. While I can do that through ctrl-clicking on the tab, automating
>it is another matter.
This works with Safari 5.1.2 in Snow Leopard:
tell application "Safari" to close (tabs of front window whose visible is false)
Or there's this, which also works with Safari 4.1.3 in Tiger (with or
without GUI Scripting enabled):
tell application "System Events"
set frontmost of application process "Safari" to true
keystroke "w" using {option down, command down}
end tell
NG
_______________________________________________
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