Opening secure URL in firefox

Hi there, I’m trying to create a really simple script to open a number of secure url’s in firefox. I have the usernames and passwords already stored in firefox, so all that needs to be done when they open is hit enter, but try as I might I can’t get Applescript to do this.

tell application "Firefox"
	OpenURL "http://xxx.xxxxxxxxxxx.com"
	tell application "Firefox" to activate
	tell application "System Events"
		key code 36
	end tell
end tell

It always seems to go to fast so it misses out on the press Enter command.

I hope somebody can help.

If by “secure”, you means uses HTTP Authentication (which is not at all the same thing as encrypted like HTTPS), then you might try something like this:

tell application "Firefox" to OpenURL "http://whatever"
set t to current date
tell application "System Events" to ¬
	repeat until exists sheet 1 of window 1 of application process "firefox-bin"
		if (current date) - t is greater than 10 then ¬
			error "Gave up waiting for authentication sheet!"
		delay 0.5
	end repeat
tell application "Firefox" to activate
tell application "System Events" to key code 36

Model: iBook G4 933
AppleScript: 1.10.7
Browser: Safari Version 4 Public Beta (4528.17)
Operating System: Mac OS X (10.4)

Edit History: Change first tell from block to statement.

That works great, your a legend.

This is asking a lot, but could you also explain how I can do this for multiple pages opening in tabs in one window. I’ve tried using the “in window 1” code. Do I have to specify a “window 1” to begin with?

OpenURL always seemed to open a new window for me even though I have Firefox set to open in tabs. Changing to Get URL seems like it opens in tabs, so you might try this:

set urlList to {¬
	"http://somewhere", ¬
	"http://somewhere-else", ¬
	"http://nowhere", ¬
	"http://last-place"}
repeat with aURL in urlList
	openURLInFirefoxAndDismissSheet(aURL)
end repeat

to openURLInFirefoxAndDismissSheet(aURL)
	tell application "Firefox" to Get URL aURL
	set t to current date
	tell application "System Events" to ¬
		repeat until exists sheet 1 of window 1 of application process "firefox-bin"
			if (current date) - t is greater than 10 then ¬
				error "Gave up waiting for authentication sheet!"
			delay 0.5
		end repeat
	tell application "Firefox" to activate
	tell application "System Events" to key code 36
end openURLInFirefoxAndDismissSheet

I fear that it may do rather unexpected things if you ever arrive in a situation where your autofilled password is not accepted.

Thanks so much.

Your awesome.