open internet explorer to a url

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
eg252
Newbie
Posts: 11
Joined: Thu Dec 02, 2004 5:32 pm

open internet explorer to a url

Post by eg252 » Thu Dec 02, 2004 5:41 pm

i tried doing this:
Run Program>C:\Program Files\Internet Explorer\iexplore.exe
WAIT >5
Press Tab
Send>http:www.yahoo.com
Press Enter

is there an easier way?

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Thu Dec 02, 2004 5:56 pm

Hi,

Yes. And your way is unreliable. What if it takes longer than 5 seconds for the page to load? You must not have discovered the Scripts & Tips archive on our web site yet or the search function on this forum because there are lots of topics about this.

Check this out at Scripts & Tips for the best way to do what you want:

https://www.mjtnet.com/scripts.hts?display+77
MJT Net Support
[email protected]

eg252
Newbie
Posts: 11
Joined: Thu Dec 02, 2004 5:32 pm

THANK YOU

Post by eg252 » Thu Dec 02, 2004 6:00 pm

I am new to this. I really appreciate your help..

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Thu Dec 02, 2004 6:12 pm

No problem.
MJT Net Support
[email protected]

Guest

Post by Guest » Thu Dec 02, 2004 9:53 pm

So is:

Run Program>C:\Program Files\Internet Explorer\iexplore.exe http://www.mjtnet.com
WaitWindowOpen>Microsoft Internet Explorer

unreliable too?

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Thu Dec 02, 2004 10:07 pm

Yes, because this only waits for Internet Explorer to be active. It doesn't know when the web page you have requested has finished loading.

The title of the web page appears in the Internet Explorer bar so you could do WaitWindowOpen>title* but this is no good either because IE puts the web pages' title in the bar before it has finished loading the rest of the page.

So the only reliable way to do it is to use a method that Internet Explorer GIVES us to use - the Busy function exposed by Internet Explorer's ActiveX interface:


Sub OpenPage(URL,Wait)
Dim IE
Set IE = CreateObject("InternetExplorer.Application")
IE.visible = 1
IE.navigate URL

do while IE.Busy and Wait
loop
End Sub


This function takes a URL and if you set Wait to 1 the loop keeps looping until Busy is no longer true. Simple, elegent, and reliable. There is no point in not using a nice feature that is there for the taking!
MJT Net Support
[email protected]

Guest

Post by Guest » Thu Dec 02, 2004 11:07 pm

Great, thanks for taking the time to explain that :D

Guest

Post by Guest » Wed Dec 29, 2004 4:12 am

support wrote: Sub OpenPage(URL,Wait)
Dim IE
Set IE = CreateObject("InternetExplorer.Application")
IE.visible = 1
IE.navigate URL

do while IE.Busy and Wait
loop
End Sub
How can I best modify this to set a maximum time to wait? In other words "if the page hasn't loaded in x seconds forget it".

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Wed Dec 29, 2004 8:15 am

Use the TimeValue and Now functions. Get the time before the loop and keep checking the time in the loop. If the timeout interval has elapsed exit the loop.
MJT Net Support
[email protected]

rusty9075
Newbie
Posts: 14
Joined: Sun Aug 27, 2006 4:46 pm

Post by rusty9075 » Sun Mar 11, 2007 4:41 am

Sub OpenPage(URL,Wait)
Dim IE
Set IE = CreateObject("InternetExplorer.Application")
IE.visible = 1
IE.navigate URL

do while IE.Busy and Wait
loop
End Sub


I a beginner at this... How do I add this code to a subroutine so that I can go to different web pages and make sure the page is fully loaded before I go to the next page
Thanks
Nate

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Sun Mar 11, 2007 4:35 pm

Those are VB Script subroutines, you define them at the beginning of the macro between VBSTART and VBEND tags and call them as many times as you need with VBRun> in the script. Like this:

//Define the VBScript subroutines
VBSTART
Dim IE
Sub CreateIE
Set IE = CreateObject("InternetExplorer.Application")
IE.visible = 1
End Sub

Sub Navigate(URL)
IE.navigate URL
End Sub

Sub WaitBusy
do while IE.Busy
loop
End Sub

Sub DestroyIE
IE.Quit
Set IE = Nothing
End Sub

VBEND

//Main Program
//Web Page1
VBRun>CreateIE
VBRun>Navigate,http://www.yahoo.com
VBRun>WaitBusy
Wait>1
SetFocus>Microsoft Internet Explorer*
WindowAction>1,Microsoft Internet Explorer*
//Do your stuff here (Wait> is just for demo)
Wait>2
//Close IE
VBRun>DestroyIE

//Web Page2
VBRun>CreateIE
VBRun>Navigate,http://www.msn.com
VBRun>WaitBusy
Wait>1
SetFocus>Microsoft Internet Explorer*
WindowAction>1,Microsoft Internet Explorer*
//Do your stuff here (Wait> is just for demo)
Wait>2
//Close IE
VBRun>DestroyIE

Label>finish

rusty9075
Newbie
Posts: 14
Joined: Sun Aug 27, 2006 4:46 pm

Thank you

Post by rusty9075 » Sat Mar 24, 2007 2:45 pm

Thanks for your help Me_Again. I appreciate you taking the time to help answer my question. YOU ROCK!! :)

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Sun Mar 25, 2007 3:45 am

You're welcome! Thanks for taking the time to let us know that you found it useful :)

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts