How can I get the URL of the document of a Safari tab that it is not the fronmost tab?
syng:
Not an easy task, but this will get the url of every tab currently available and put them in a list:
set url_list to {}
tell application "System Events"
tell application "Safari" to activate
repeat
tell process "Safari" to keystroke "}" using command down
try
tell application "Safari" to set this_url to the URL of every document
end try
if {this_url} is not in url_list then
set end of url_list to this_url
else
exit repeat
end if
end repeat
tell process "Safari" to keystroke "h" using command down
end tell
url_list
Thanks. But what I need is to get the URL without activating Safari and without navigating trough the tabs.
Something like this:
set URLTabs to (the URL of every tab of window 1)
syng:
Unfortunately, Safari is simply not that scriptable. If you look in the Safari dictionary, you will find zero references to tabs at all. You should also understand that unless Safari is active, it can have no tabs anyway, so trying to obtain such information from an inactive application would be futile.
If you could offer a few more details concerning your project, it may be easier to provide assistance.
Craig is right. Currently, the only web browser that gives AppleScript access to its tabs is OmniWeb. So, if you must have tabs and must have access to them via AppleScript, you’ll need to get OmniWeb. I think it’s worth the $30 if you need what it has to offer (much more than proper AppleScript access - site-specific preferences, blocking, and more), custom text boxes for web forms, and much more.
Perhaps, though, what you are trying to do won’t necessarily require tabs?