Keeping a loop in the same web browser

Basically I’m trying to loop an action”making a post on a certain forum with IE, and I got pretty much got it to work except it repeats the action in a separate window, and I want the action in only one.

tell application “Internet Explorer”
repeat 5 times
OpenURL “http://www.forumplanet.com/doc/post.asp?fid=1421&tid=1651324&rid=18689244&t=3&rn=test” toWindow 1
delay 8
OpenURL “javascript:checkRequired(frmNew, true);”
end repeat
end tell

After it hits submit (which is the javascript:checkrequired thing) it redirects to the topic and opens a new window. Any thoughts?

(Oh, and can Safari handle javascript with applescript? I can’t seem to get it to work.)

Browser: Safari 85.8.1
Operating System: Mac OS X (10.4)

Have you tried “do script blah”, instead of “OpenURL blah”? (for the javascript thing)
In Safari, it’s similar:

tell app "Safari"
     do javascript "blah" in document 1
end

yeah that doesn’t work. explorer’s the closest i’ve gotten.

Browser: Safari 85.8.1
Operating System: Mac OS X (10.4)

anyone have any ideas? all i want is the action to repeat in the same window.

Browser: Safari 85.8.1
Operating System: Mac OS X (10.4)

…Hullo.

You must set your Preferences from the Explorer menu, Interface Extras option:
“When another app asks IE to go to a page”->{use front browser window}

once you do that, the code

has the repeat outside the “tell” statement. Move the repeat around the whole block


repeat 5 times
	tell application "Internet Explorer"
		
		OpenURL "http://www.forumplanet.com/doc/post.asp?fid=1421&tid=1651324&rid=18689244&t=3&rn=test"

delay 8--*The delay in seconds must be set to "longer than it takes to load the page"

OpenURL "javascript:checkRequired(frmNew, true);"
		
	end tell
	delay 5--*The delay in seconds must be set to "longer than it takes to load the page"
end repeat

The delays wait for the pages to load so every thing runs smoothly. I’m on cable modem, so a 56k would have a substantially larger delay.
SC

IE users:
http://scriptbuilders.net/files/bbspost2script1.x1.9.html
Freeware: Auto post scripts into script editor window from IE

Ah, thank you.

Okay, just one more question. Is there a way to open multiple windows at the same time? As in “openurl http://www.blahblahblah.com 3 times”, but in correct syntax.


tell application "Internet Explorer"
	repeat 3 times
		run
	end repeat
end tell

That opened 3 windows at the same time. If you wanted to combine that with the previous script so that each window ran the process:


tell application "Internet Explorer"
	repeat 3 times
		run
		repeat 5 times
			tell application "Internet Explorer"
				
				OpenURL "http://www.forumplanet.com/doc/post.asp?fid=1421&tid=1651324&rid=18689244&t=3&rn=test"
				
				delay 8 --*The delay in seconds must be set to "longer than it takes to load the page"
				
				OpenURL "javascript:checkRequired(frmNew, true);"
				
			end tell
			delay 5 --*The delay in seconds must be set to "longer than it takes to load the page"
		end repeat
	end repeat
end tell


SC

Well the first one worked, but the second one doesn’t actually open multiple windows. I messed around with the script a little, but I’m stumped.

Edit: I sorta got it to work. It opens multiple windows, but it waits for the first window to finish before it moves on to the second.


tell application "Internet Explorer"
	repeat 3 times
		run
	end repeat
	repeat 5 times
		tell application "Internet Explorer"
			
			OpenURL "http://www.forumplanet.com/maddipper/post.asp?fid=1481&tid=1678160&t=2&rn=gg"
			
			delay 8 --*The delay in seconds must be set to "longer than it takes to load the page" 
			
			OpenURL "javascript:checkRequired(frmNew, true);"
			
		end tell
		
		
		
	end repeat
end tell