Re: Safari reload script.
Re: Safari reload script.
- Subject: Re: Safari reload script.
- From: kai <email@hidden>
- Date: Mon, 25 Oct 2004 04:58:13 +0100
On Sun, 24 Oct 2004 12:08:46 -0700, Jordan Rickards wrote:
I am new to applescript and trying to do the following. I work at an
apple reseller and we use gsx a lot. GSX has a time out feature that
gets really annoying. We want a way in the back ground for a apple
script to reload the gsx page, if it is open. The script I have is as
follows. I need some help doing the following. This scripts errors
if there is no safari window open, and also if safari is not open. I
would like the script to just ignore it self when there are no windows
and also when Safari is not open. I thought the on error would do
that but it does not seem so. It would also would be nice if message
box would come up and ask you to reload just incase the user is in the
middle of something. But if the user is not there it would select the
option to reload after like 10 seconds or so. I hope I'm not asking
to much. It would also be nice for the applescript to look at
multiple tabs/windows and find the one with gsx in it but I'm not sure
if that is possible. Thanks in advance for any help
This suggestion attempts to reload the page in the background, as long
as Safari has a document with a relevant URL. A dialog is displayed
only when the user appears to have a GSX page in front.
I've no idea what the GSX timeout would be, so modify the value of the
'idleTime' property below - so that it's slightly less than the normal
timeout.
Not tested exhaustively - but it may give you one or two additional
ideas...
--------------------------
property idleTime : 600 -- (seconds)
property urlStr : "gsx.apple.com "
on idle
tell application "System Events" to tell process "Safari"
if not (exists) then return idleTime
set safariFrontmost to frontmost
end tell
tell application "Safari"
set frontDoc to document 1
tell (first document whose URL contains urlStr)
if not (exists) then return idleTime
if safariFrontmost and it is frontDoc then display dialog "Reload
GSX to avoid a timeout?" with icon 1 giving up after 10
do JavaScript "window.location.reload()" in it
end tell
end tell
idleTime
end idle
--------------------------
---
kai
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden