VBScript Fill Web Login Form - vbscript

I can't figure out how can I fill Login Form with User and Pass and click on "OK" button.
I've tried several variants and nothing has been typed.
I made also I print screen with html code for each form.
On error resume next
Dim WshShell, objIE, ElementCol
Dim LinkHref
LinkHref = "https://www...."
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Visible = False
objIE.Navigate LinkHref
wshShell.AppActivate objIE
Do While objIE.Busy
wscript.sleep 100
Loop
Set ElementCol = objIE.Document.getElementsByTagName("a")
For Each Link In ElementCol
If Link.innerHTML = "Continue to this website (not recommended)." Then
Link.Click
Exit For
End If
Next
objIE.Visible = True
objIE.Document.All.Item("S01LOGIN").value = "myusername"
'objIE.Document.getElementByName("S01LOGIN").Value = "myusername"
'objIE.document.getElementById("S01LOGIN").value = "myusername"
objIE.Document.All.Item("S02PASS").value = "mypass"
'objIE.Document.getElementByName("S02PASS").Value = "mypass"
'objIE.document.getElementById("S02PASS").value = "mypass"
I use IE11 and I think this is the problem

Related

How can I use an already open IE with VB Script? GetObject is not working

Below is the code block i used to open a new window. I tried using GetObject in place of Create Object as below. But did not work.
Set IE = GetObject("","InternetExplorer.Application")
'
Dim IE
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.navigate "https://msn.com"
Do While IE.ReadyState <> 4
WScript.Sleep 1000
Loop
Set ElementCol = IE.Document.getElementsByTagName("a")
For Each Link In ElementCol
If Link.innerHTML = "News" Then
Link.Click
WScript.Sleep(6000)
Exit For
End If
Next
IE.navigate "https://msn.com"
This uses Explorer which used to do the internet.
Set objShell = CreateObject("Shell.Application")
Do
Set AllWindows = objShell.Windows
Count = 0
For Each window in AllWindows
msgbox window.locationname
' window.refresh2 3
Count = Count + 1
Next
If Count = 0 then Exit Do
Wscript.sleep 5000
Loop

error looping thru input tags using vbscript

If I open IE and go to the page I need this works
LocationURL = "https://secure4.billerweb.com/smg/BillerConsole/inetSrv?sessionHandle=oGWmOV1RQAkSijIxSWs8IjcShm7x4dZir/nuGysZmGsoWXrUY2w9NzE5MTMwNzAw&client=719130700&type=ApplicationMenu&action=Menu"
Set ie = GetIEApp(LocationURL)
Set aHTML = IE.document
Set frames = aHTML.getElementsByTagName("frame")
For Each frame In frames
Set inputs = frame.contentwindow.document.getElementsByTagName("input")
For Each obj In inputs
If obj.name = "serviceSelection.inputFieldList[0].accountNumber" Then
obj.value = "123"
End If
If obj.name = "serviceSelection.inputFieldList[0].reEnterAccountNumber" Then
obj.value = "123"
End If
If obj.value = "Continue" Then
obj.click
End If
Next
Next
Public Function GetIEApp(Location)
Dim objShell
Dim objWindows
Dim objWindow
Set objShell = CreateObject("Shell.Application")
Set objWindows = objShell.Windows
For Each objWindow In objWindows
If LCase(Left(objWindow.LocationURL,4)) = "http" Then
If LCase(Right(objWindow.FullName, 12)) = "iexplore.exe" Then
If InStr(objWindow.LocationURL,Location) Then
Set GetIEApp = objWindow
End If
End If
End If
Next
Set objWindow = Nothing
Set objWindows = Nothing
Set objShell = Nothing
End Function
If I use the script to open IE and login then go to the page I get an error
Object doesnt support this property or method 'frame.contentwindow.document.getElementsByTagName("input")'
Set IE = CreateObject("InternetExplorer.Application")
Set WshShell = WScript.CreateObject("WScript.Shell")
IE.Navigate "https://secure4.billerweb.com"
IE.Visible = True
While ie.Busy : WScript.Sleep 100 : Wend
IE.Document.All.Item("loginid").Value = "myid"
IE.Document.All.Item("password").Value = "mypass"
IE.Document.getElementsByName("Login").Item(0).Click
While ie.Busy : WScript.Sleep 100 : Wend
WScript.Sleep 1000
Call IE.document.parentWindow.execScript("top.header.selectGroup('1', 1)", "JavaScript")
WScript.Sleep 500
Call IE.document.parentWindow.execScript("top.header.preSubmit('inetSrv?type=WizardService&" & client & "&newBean=true')", "JavaScript")
While ie.Busy : WScript.Sleep 100 : Wend
WScript.Sleep 1000
Set aHTML = IE.document
Set iframes = aHTML.getElementsByTagName("frame")
For Each frame In iframes
Set inputs = frame.contentwindow.document.getElementsByTagName("input")
For Each obj In inputs
If obj.name = "serviceSelection.inputFieldList[0].accountNumber" Then
obj.value = "123"
End If
If obj.name = "serviceSelection.inputFieldList[0].reEnterAccountNumber" Then
obj.value = "123"
End If
If obj.value = "Continue" Then
obj.click
End If
Next
Next
I figured it out.
Changed
Set inputs = frame.contentwindow.document.getElementsByTagName("input")
to
Set inputs = frame.contentDocument.getElementsByTagName("input")

VB Script for auto Login into website giving an error

I am using below VB script for auto login in to website. It is entering username but it does not enter password and gives the error that 'doesn't support this property or method' . I have not worked in VB script , so not sure why this error is coming.
On Error Resume Next
Const PAGE_LOADED = 4
Set objIE = CreateObject("InternetExplorer.Application")
Call objIE.Navigate("http://www.gmail.com")
objIE.Visible = True
Do Until objIE.ReadyState = PAGE_LOADED : Call WScript.Sleep(100) : Loop
objIE.Document.all.username.Value = "username"
objIE.Document.all.Passwd.Value = "password"
If Err.Number <> 0 Then
msgbox "Error: " & err.Description
End If
Call objIE.Document.all.login_form.submit
Set objIE = Nothing
Try if this code can did the trick or not because gmail has changed its source code !
Dim IE
Set IE = Wscript.CreateObject("InternetExplorer.Application")
IE.Visible = 1
IE.navigate("https://accounts.google.com/ServiceLogin?service=ig&passive=true&continue=http://www.google.com/ig%3Fhl%3Den&followup=http://www.google.com/ig%3Fhl%3Den&cd=US&hl=en&nui=1&ltmpl=default")
Do While (IE.Busy)
WScript.Sleep 10
Loop
Set Helem = IE.document.getElementById("Email")
Helem.Value = "Your Login goes here" 'Change to your Gmail login
Set Helem = IE.document.Forms(0)
Helem.Submit
Do While (IE.Busy)
WScript.Sleep 10
Loop
wscript.sleep 2000
Set Helem = IE.document.getElementById("Passwd")
Helem.Value = "Your Password goes here" 'Change to your Gmail password
Set Helem = IE.document.Forms(0)
Helem.Submit

VBscript Object required 800A01A8

Please help. cant make this code work. It requires an object. Don't know how to resolve this. I see no typo error on my script. I am trying to check if there is an Internet Explorer that is open to https://www.test.com in my PC. Badly needed for a school project. Thanks in advance
Option Explicit
Dim objShell, objShellWindows, i, objIE
Set objShell = CreateObject("Shell.Application")
Set objShellWindows = objShell.Windows
For i = 0 to objShellWindows.Count - 1
Set objIE = objShellWindows.Item(i)
strURL = objIE.LocationURL
If InStr(strURL, "https://www.test.com/")Then
blnFound = True
End If
Next
Below code will check all the URLs loaded in the IE,
Note that here bFound is True when sURL is inside .LocationURL, not begin with. Modify to suit your need.
Option Explicit
Const sURL = "https://www.test.com/"
Dim oShell, oWindow, oIE, bFound
Set oShell = CreateObject("Shell.Application")
bFound = False
For Each oWindow In oShell.Windows
If InStr(1,oWindow.Fullname,"iexplore.exe",vbTextCompare) > 0 Then
Set oIE = oWindow
With oIE
'Wscript.Echo .LocationURL
bFound = (InStr(1,.LocationURL,sURL,vbTextCompare) > 0)
If bFound Then Exit For
End With
Set oIE = Nothing
End If
Next
If bFound Then
Wscript.Echo sURL & " is loaded"
Else
Wscript.Echo sURL & " is NOT loaded"
End If
Set oShell = Nothing

Show msg box in less than a second

Is there a way to make a msgbox show and disappear in under a second,I have been using the script below, but can only get it to close in a second.
Option Explicit
Dim Wshell, BtnCode
Set Wshell = CreateObject("wscript.shell")
BtnCode= Wshell.Popup ("test", 1, "testing")
I'm afraid this is not possible with popup.
You can do it with Internet Explorer as UI though.
Set oIE = CreateObject("InternetExplorer.Application")
With oIE
.navigate("about:blank")
.Document.Title = "Countdown" & string(100, chrb(160))
.resizable=0
.height=200
.width=100
.menubar=0
.toolbar=0
.statusBar=0
.visible=1
End With
' wait for page to load
Do while oIE.Busy
wscript.sleep 50
Loop
' prepare document body
oIE.document.body.innerHTML = "<div id=""countdown"" style=""font: 36pt sans-serif;text-align:center;""></div>"
oIE.document.all.countdown.innerText= "test message"
'the parameters is in miliseconds, so here the message is shown for half a second
wscript.sleep 500
oIE.quit

Resources