Link to home
Start Free TrialLog in
Avatar of leokuz
leokuzFlag for United States of America

asked on

VBScript to delay until full page load

I am wondering if there is a way to modify this auto login code so that it would run immediately after the entire html page has been loaded.

I don't like this code as it is now because if page loads to fast, then I end up waiting 4.5 seconds looking at the login prompt, but if I specify less time, then when page loads too slow, the code runs long before page fully loaded and we get to nowhere. By default the cursor on subject page sits in username's field. I have no control over the subject html page. Please help if you can.

Here is the code:

'-----------------------------------------------------'
Option Explicit
Dim objShell
Set objShell = CreateObject("WScript.Shell")
objShell.Run "http://www.somewebsite.com"
Wscript.Sleep 4500
objShell.SendKeys "username"
objShell.SendKeys "{TAB}"
Wscript.Sleep 100
objShell.SendKeys "password"
objShell.SendKeys "{ENTER}"
WScript.Quit
'-----------------------------------------------------'
ASKER CERTIFIED SOLUTION
Avatar of sirbounty
sirbounty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of leokuz

ASKER

I've tried, but for some reason neither IE opens nor I get any errors.
Avatar of leokuz

ASKER

Never mind. I have included "Option Explicit" on top and it worked. Thank you :))
Avatar of leokuz

ASKER

What this do in your script?

set objIE=Nothing
Set objShell=Nothing
Just terminates the objects - good coding practice...
Avatar of leokuz

ASKER

Actually it wasn't adding "Option Explicit" that fixed the problem, but changing objIE.Navigate "http://www.msn.com" to objIE.Navigate("http://www.msn.com")

Thought its important to mention for someone's future use.

Thanks for your lightning speed help sirbounty.
Happy to help. :^ )
Thanx.