Control Internet Explorer from VB Script using the Internet Explorer COM object. The code below shows how to do the following:
- Open Internet Explorer
- Navigate to different URL’s
- Make Internet Explorer visible/invisible
- Populate a textbox on a web page
- Click a button on a web page
You can use scripts like this to automate anything you do repeatedly to save time, such as: Web logins, screen captures, fake traffic or vote in internet polls. I used a script similar to this one to enter my self in a drawing for a new house, I set the script up on the windows scheduler to run once a day since the contest specified that you were allowed to enter once daily. I didn't win!
Code – *.vbs
' Put your name into the "Search" textbox
' Notice below that the textbox's name is "q"
oIE.document.all.q.value = "Rick Casady"
' Click the Search button
' Notice below that the button's name is "q"
' Create a Internet Explorer COM object and then Navigate the Navigate sub
' Also sets the Internet explorer to be visible
Public Sub IeNew(ByVal strURL)
Set oIE = CreateObject("InternetExplorer.Application")
oIE.Visible = True
' Navigates to the URL provided then waits for IE to complete.
Public Sub Navigate(ByVal strURL)
Loop Until Not oIE.Busy