I must login to my isp to be able to use my broadband connection. I had an idea that maybee I could get applescript to do the whole login process for me. I can manually press the tabkey to get the cursor moved to the last field of the login page and if I press enter there I get logged in. I cant get applescript to accept the tabkey however - I’ve tried “keystroke tab” but that doesn’t work and I can’t just write in “tab” in the code cause that’s converted to “tab group” when I save.
Just clicking the login button would be an even better idea but I don’t know how to script that either.
launch application "Safari"
set login_url to ("http://the adress")
tell application "Safari"
activate
tell application "System Events"
try
tell application "Safari" to do JavaScript "document.location.href = '" & (login_url) & "'" in document 1
delay 8
--tab group
keystroke enter
--keystroke "m" with command down
end try
end tell
end tell
Thanks alot now it works like a charm. Here’s how it looks now:
launch application "Safari"
set login_url to ("http://the adress")
set the_urls to {"http://www.kingfeatures.com/features/comics/zits/aboutMaina.php", "http://www.macaddict.com/", "http://www.macaddict.com/phpBB2"}
tell application "Safari"
activate
tell application "System Events"
try
tell application "Safari" to do JavaScript "document.location.href = '" & (login_url) & "'" in document 1
delay 8
keystroke (ASCII character 9)
keystroke (ASCII character 9)
keystroke (ASCII character 13)
delay 2
--keystroke "m" with command down
end try
delay 5
try
keystroke "n" with command down
repeat with i from 1 to (count of the_urls)
keystroke "t" with command down
tell application "Safari" to do JavaScript "document.location.href = '" & (item i of the_urls) & "'" in document 1
end repeat
end try
--keystroke "m" with command down
end tell
end tell
It’s only a small part of a huge script that’s launched at startup