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 6
bfuchsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

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
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.