Go Back   The macosxhints Forums > OS X Help Requests > Applications



Reply
 
Thread Tools Rate Thread Display Modes
Old 03-04-2005, 09:00 AM   #1
stephenpen543
Triple-A Player
 
Join Date: Nov 2004
Posts: 77
Question Applescript for reloading web page

Sometimes, on Safari (or any web brower)
I have to keep on reloading the page.
I want an apple script to to do this rather than keep on pressing Command-R, but can't find any.
Can anybody help.
I done a type of version, but its a bit rubbish, and doesn't work!
Here it is neway:
tell application "Firefox"
keystroke command + (ASCII character 114)
repeat 10 times
end repeat
end tell

the problem is the command button, as I can't find an ASCII character, can anybody help. Also, is there any way that I can make it repeat it self after something like a minute?
Thanks in advance, and sorry if I put this in the wrong place.
__________________
I ain't what i should be,
I ain't what i will be,
but I ain't what i was.
stephenpen543 is offline   Reply With Quote
Old 03-04-2005, 09:30 AM   #2
Carl Stawicki
Triple-A Player
 
Join Date: Aug 2004
Location: Cleveland, OH
Posts: 168
The gist of what you need is simply this:
Code:
repeat
	open location "http://www.apple.com"
	delay 60
end repeat
"Open location" is part of the Standard Addition, so you don't need to script a particular browser; it will work on whatever browser you have set to your default. It will repeat infinitely, every 60 seconds.

Carl.
Carl Stawicki is offline   Reply With Quote
Old 03-04-2005, 11:32 AM   #3
cudaboy_71
All Star
 
Join Date: Jan 2002
Location: sacramento, ca
Posts: 857
im just learning AS myself. but, as far as i know the only access you have to the command, control, option, shift buttons is via UI scripting. to enable that you need to go to System Preferences->Universal Access and check the 'Enable Access for Assistive Devices'.

then, you can communicate directly with system events as opposed to the application itself.

additionally, if you want to reload pages periodically but dont explicitly release the script from hogging the processor you will cause AS to eat up cycles. so, i'd use the idle command to page the system for the action.

something like this:

Code:
on idle
-- the applescript only calls attention to itself when the idle period is up

tell application "Safari"
--confirms your browser is the front application
		activate
	end tell
	
	tell application "System Events"
		tell process "Safari"
			keystroke "r" using {command down}
		end tell
	end tell
--sets the idle period in seconds. i.e. safari will refresh every 10 seconds
	return 10
end idle
save this code as an 'always open' application. when you run it, safari will refresh indefinitely every 10 seconds.
cudaboy_71 is offline   Reply With Quote
Old 03-04-2005, 12:33 PM   #4
stephenpen543
Triple-A Player
 
Join Date: Nov 2004
Posts: 77
Thumbs up

Thank you both, Carl and cudaboy. You both helped a lot.
I know a bit more about AS! Yay!
Thanks again
__________________
I ain't what i should be,
I ain't what i will be,
but I ain't what i was.
stephenpen543 is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 01:51 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Site design © Mac Publishing LLC; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of Mac Publishing LLC.