Looking for script to auto open site with credentials filled in.

Hi Experts,
I would like to have a script/function that opens the following site
https://pages.caspio.com/login/bridgelogin/default.aspx?_ga=2.157757818.1116850724.1518037460-1462101065.1512014265
fills in the account, username and password.
See attached.
Should either be done thru Access VBA or via script.
Thanks in advance.
Untitled.png
LVL 5
bfuchsAsked:
Who is Participating?
 
rastoiWindows DTS expertCommented:
Your attempt was close, but respective fields IDs are EmailField and PasswordField
here is updated code, which works for me
$email='test@test.id'
$password='pa$$word'

Add-Type -AssemblyName System.Windows.Forms
Add-Type @"
 using System;
 using System.Runtime.InteropServices;
 public class StartActivateProgramClass {[DllImport("user32.dll")][return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetForegroundWindow(IntPtr hWnd);}
"@

$ie = New-Object -ComObject InternetExplorer.Application
Do {Start-Sleep 1} Until (!($IE.Busy))
$ie.Navigate('https://pages.caspio.com/login/bridgelogin/default.aspx?_ga=2.157757818.1116850724.1518037460-1462101065.1512014265')
Do {Start-Sleep 5} Until (!($IE.Busy))
$ie.Visible=$true
[void] [StartActivateProgramClass]::SetForegroundWindow($ie.HWND)
([System.__ComObject].InvokeMember('getElementById',[System.Reflection.BindingFlags]::InvokeMethod,$null,$ie.document,'EmailField')).value=$email
([System.__ComObject].InvokeMember('getElementById',[System.Reflection.BindingFlags]::InvokeMethod,$null,$ie.document,'PasswordField')).value=$password
([System.__ComObject].InvokeMember('getElementById',[System.Reflection.BindingFlags]::InvokeMethod,$null,$ie.document,'EmailField')).focus()
[System.Windows.Forms.SendKeys]::SendWait(" {BS}")
([System.__ComObject].InvokeMember('getElementById',[System.Reflection.BindingFlags]::InvokeMethod,$null,$ie.document,'PasswordField')).focus()
[System.Windows.Forms.SendKeys]::SendWait(" {BS}{Enter}")

exit

Open in new window

0
 
rastoiWindows DTS expertCommented:
on page you want to logon, there is quite nice job done from developer side to avoid robots click trough. Anyhow, it is possible and here is the powershell script to open yuor internet explorer, pass the credentials and click login. I have not proper credentials, so get only invalid account, please fill variables in first lines and test on your side
$login='account_ID'
$user='username'
$password='pa$$word'

Add-Type -AssemblyName System.Windows.Forms
Add-Type @"
 using System;
 using System.Runtime.InteropServices;
 public class StartActivateProgramClass {[DllImport("user32.dll")][return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetForegroundWindow(IntPtr hWnd);}
"@

$ie = New-Object -ComObject InternetExplorer.Application
Do {Start-Sleep 1} Until (!($IE.Busy))
$ie.Navigate('https://pages.caspio.com/login/bridgelogin/default.aspx?_ga=2.157757818.1116850724.1518037460-1462101065.1512014265')
Do {Start-Sleep 5} Until (!($IE.Busy))
$ie.Visible=$true
[void] [StartActivateProgramClass]::SetForegroundWindow($ie.HWND)
($ie.Document.getElementsByTagName('a')|? {$_.classname -eq 'AdvancedUserLink'}).click()
([System.__ComObject].InvokeMember('getElementById',[System.Reflection.BindingFlags]::InvokeMethod,$null,$ie.document,'AccountName')).value=$login
([System.__ComObject].InvokeMember('getElementById',[System.Reflection.BindingFlags]::InvokeMethod,$null,$ie.document,'Username')).value=$user
([System.__ComObject].InvokeMember('getElementById',[System.Reflection.BindingFlags]::InvokeMethod,$null,$ie.document,'Password')).value=$password
([System.__ComObject].InvokeMember('getElementById',[System.Reflection.BindingFlags]::InvokeMethod,$null,$ie.document,'AccountName')).focus()
[System.Windows.Forms.SendKeys]::SendWait(" {BS}")
([System.__ComObject].InvokeMember('getElementById',[System.Reflection.BindingFlags]::InvokeMethod,$null,$ie.document,'Username')).focus()
[System.Windows.Forms.SendKeys]::SendWait(" {BS}")
([System.__ComObject].InvokeMember('getElementById',[System.Reflection.BindingFlags]::InvokeMethod,$null,$ie.document,'Password')).focus()
[System.Windows.Forms.SendKeys]::SendWait(" {BS}{Enter}")

exit

Open in new window


of course, for real life I would save encrypted password into file and decode only for login (using powershell securestring, but it is for another question ;-)
Small small trouble can occure, if you (or some other application) change the focus during logon, but password is protected from displaying on such event.
1
 
bfuchsAuthor Commented:
Hi Rastoi,

First thanks for the work.
Was not at work yet.
Will soon test it & reply.

Thanks,
Ben
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
bfuchsAuthor Commented:
Hi,
I saved as .ps1, then opened with notepad and put the credentials.
Now when run as powershell nothing happens.

Thanks,
Ben
0
 
rastoiWindows DTS expertCommented:
Hi Ben,
How are you running it? In console?
Really nothing no error, no message, just ends?
0
 
bfuchsAuthor Commented:
By right click, choose run as powershell.
Not really familiar with powershell..
A black screen pops up but closes after a few sec..

Thanks,
Ben
0
 
rastoiWindows DTS expertCommented:
Please, open powershell console i.e. start/run: powershell
Start saved script by using full path  to file, and put result here together with informatio which version of operating system ate you using.
In my timezone is 1pm now, so I will check in about 8 hours.
0
 
bfuchsAuthor Commented:
Hi,
See attached error when followed steps above.
Thanks,
Ben
Untitled.png
0
 
bfuchsAuthor Commented:
Actually I got that above fixed.
Now it did tried to connect but got the attached errors.

Thanks,
Ben
Untitled.png
0
 
bfuchsAuthor Commented:
Hi,

OK I realized that guess during this weekend they changed somehow their login screen.
Currently this is how it looks
https://id.caspio.com/?_ga=2.154520880.944330641.1518404630-2087572457.1512014159
See attached.
Note- Instead of AccountID user name and password, they now require email and password.
Perhaps we just need to modify your code accordingly..

Thanks,
Ben
Untitled.png
0
 
bfuchsAuthor Commented:
Did try updating as follows.
$login='***'
$user='MyEmail'
$password='MyPwd'

Add-Type -AssemblyName System.Windows.Forms
Add-Type @"
 using System;
 using System.Runtime.InteropServices;
 public class StartActivateProgramClass {[DllImport("user32.dll")][return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetForegroundWindow(IntPtr hWnd);}
"@

$ie = New-Object -ComObject InternetExplorer.Application
Do {Start-Sleep 1} Until (!($IE.Busy))
$ie.Navigate('https://pages.caspio.com/login/bridgelogin/default.aspx?_ga=2.154520880.944330641.1518404630-2087572457.1512014159')
Do {Start-Sleep 5} Until (!($IE.Busy))
$ie.Visible=$true
[void] [StartActivateProgramClass]::SetForegroundWindow($ie.HWND)
($ie.Document.getElementsByTagName('a')|? {$_.classname -eq 'AdvancedUserLink'}).click()

([System.__ComObject].InvokeMember('getElementById',[System.Reflection.BindingFlags]::InvokeMethod,$null,$ie.document,'email')).value=$user
([System.__ComObject].InvokeMember('getElementById',[System.Reflection.BindingFlags]::InvokeMethod,$null,$ie.document,'Password')).value=$password
([System.__ComObject].InvokeMember('getElementById',[System.Reflection.BindingFlags]::InvokeMethod,$null,$ie.document,'Email')).focus()
[System.Windows.Forms.SendKeys]::SendWait(" {BS}")

([System.__ComObject].InvokeMember('getElementById',[System.Reflection.BindingFlags]::InvokeMethod,$null,$ie.document,'Password')).focus()
[System.Windows.Forms.SendKeys]::SendWait(" {BS}{Enter}")

exit

Open in new window

Got the attached.

Thanks,
Ben
Untitled.png
0
 
bfuchsAuthor Commented:
Thanks very much rastoi!
btw, I'm planning to have a few such requests in near future, will post a link here..
just wondering, are you also familiar with Access VBA?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.