Re: Re: Accessing Tabs in Safari
Re: Re: Accessing Tabs in Safari
- Subject: Re: Re: Accessing Tabs in Safari
- From: Michael Schmidt <email@hidden>
- Date: Thu, 27 Nov 2003 09:36:37 +0100
I would like to refresh all tabs in Safari via Applescript.
So I want to walk through all tabs doing the following:
tell application "Safari"
set p to count windows
repeat with i from 1 to p
set thisURL to URL of document 1 of window i
do JavaScript "self.location=\"" & thisURL & "\";" in document 1 of
window i
end repeat
end tell
You can't. The only answer is to ask apple to expose the tabs in
applescript, which they haven't done.
I tried the whole day and did it via GUI Scripting and System Events:
on refreshAll()
-- to get access to the window, it must be visible
set isMinimized to false
set isHidden to false
tell application "Safari"
set isHidden to not visible of window 1
if isHidden then
set isMinimized to miniaturized of window 1
if isMinimized then
set miniaturized of window 1 to false
set isHidden to false
end if
end if
end tell
set activeTab to 1
if isHidden then
tell application "Safari" to set visible of window 1 to true
end if
-- the real script starts here
tell application "System Events"
tell process "Safari"
set tabCount to count radio buttons of window 1
repeat with i from 1 to tabCount
if value of attribute "AXValue" of radio button i of window 1 = 1
then
-- to activate the now active tab after doing the refreshs
set activeTab to i
end if
end repeat
repeat with i from 1 to tabCount
-- activate each tab
click radio button i of window 1
-- tell it to refresh via JavaScript
tell application "Safari"
tell window 1
set thisURL to URL of document 1
do JavaScript "self.location=\"" & thisURL & "\";" in document 1
end tell
end tell
end repeat
-- return to the starttab
click radio button activeTab of window 1
end tell
end tell
if isMinimized then
-- if the window was minimized, minimize it again
tell application "Safari" to set miniaturized of window 1 to true
end if
if isHidden then
-- if the window was hidden, hide it again
tell application "Safari" to set visible of window 1 to false
end if
end refreshAll
Thanks,
Michael Schmidt
Hamburg
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.