wepee

How to auto login a web page on local NAS using IE?

12 posts in this topic

Hello all,

First of all I have no programming and no html knowledge.:>

So I some help here from someone who knows it all.

Why I need to use AutoIt.......

I have a synology NAS, installed Synology Surveillance Station package, which runs like a NVR (Network Video Recorder) 

for my mum's home CCTV surveillance.

On a separate PC, I have a Windows 7 x64. In order to do CCTV live viewing, I need to run IE and login the web page

to check out what is happening. This PC is running 24/7 non stop. That is IE is running day and night, non stop.

The problem is every time there is a Power interruption, my windows PC will reboot and then I have to login manually.

It is not a problem if it hapens at my home, but it is a real problem when I have to drive to my mum's home, to do it

manually for her as she does not know how to use computer.

 

I cannot afford to buy a UPS, because it has already being used for the NAS itself.

So, I decide to find a way to do auto login to IE, when the Windows 7 reboots every time there is a power glitch.

As usual, before I beg someone for help:D, I tried to help myself, by doing a seach on Google.

I came across this person from youtube, sharing how to do auto login using IE for logging into a website:

Here is the link: AutoIT - how to make an auto login bot

However, I am stuck, I rung Chrome browser, and do "inspect element" on the web page.

I cannot find out what is the username and password to fill in.

That is I need to fill the top line is "admin" and bottom line is "123456" on the login page.

Please see the attachment. 

Most appreciate if someone can provide me some guidance.

Thank you.

Chrome_Browser_SSS_Login_Element.jpg

AutoIt_editor.jpg

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Welcome to the forum.

First screenshot is very helpfull but the second should be posted as code, just look here:  How to post code on the forum 

 

And here is example what you need to do:

Local $oIFrame = _IEGetObjById($oIE, 'login_iframe')
Local $oUserName = _IEGetObjById($oIFrame, '....') ; I suppouse that this ID is in one TD element above
Local $oPassword = _IEGetObjById($oIFrame, 'login_passwd')

 

mLipok

 

Edited by mLipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

#include <IE.au3>

Call ("SignIn")

Func SignIn ()
    Global $oIE = _IECreate ("http://192.168.1.251/sss")

   Local $oIFrame = _IEGetObjById($oIE, 'login_iframe')
   Local $oUserName = _IEGetObjById($oIFrame, '....') ; I suppouse that this ID is in one TD element above
   Local $oPassword = _IEGetObjById($oIFrame, 'login_passwd')

    _IEFormElementSetValue ($oUserName, "admin")
    _IEFormElementSetValue ($oPassword, "123456")

    EndFunc

Hi, mLipok,

Thank you for replying. 

I am really a noob here:), I just basically do a copy and paste job.

But there is an error....... The username is blank, what I have wrong here? The password is ok.

By right there should 2 variables, username and password, right? 

What does the "$oFrame" variable means? 

Below is the error message:

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\marcus\Documents\Open_up_IE_create_sss_login.au3"    
--> IE.au3 T3.0-2 Warning from function _IEGetObjById, $_IESTATUS_NoMatch (....)
--> IE.au3 T3.0-2 Error from function _IEFormElementSetValue, $_IESTATUS_InvalidDataType
>Exit code: 0    Time: 2.098

 

Edited by wepee

Share this post


Link to post
Share on other sites

focus on this line:

Local $oUserName = _IEGetObjById($oIFrame, '....') ; I suppouse that this ID is in one TD element above

You should find correct ID in HTML DOMTree, and replace it with '....'

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Here is a functional GUI that auto logins to Facebook. I cut this piece out of a previous project. If any have any questions, feel free to ask.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <GDIPlus.au3>

HotKeySet("{ESC}", "Terminate")

;;==============================================================================;;
;;==============================VARIABLES=======================================;;
;;==============================================================================;;
;;==============================================================================;;


;;==============================================================================;;
;;======================END======VARIABLES======================================;;
;;==============================================================================;;
;;==============================================================================;;

;;==============================================================================;;
;;===============================GUI DESIGN======================================;;
;;==============================================================================;;
;;==============================================================================;;


$width = 800
$height = 625
_IEErrorHandlerRegister()
#Region ### START Koda GUI section ### Form=
$hMain = GUICreate("GUI TITLE", 1015, 585, @DesktopWidth / 2 - $width / 2, @DesktopHeight / 2 - $height / 2, _
        $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)

$wPos = WinGetPos($hMain)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;;==============================================================================;;
;;===============================WEBPAGE========================================;;
;;=======================================CODE===================================;;
;;==============================================================================;;

Local $oIE = _IECreateEmbedded()
GUICtrlCreateObj($oIE, 0, 0, $width + 0, $height + 0)
_IENavigate($oIE, "https://apps.facebook.com/clash-of-kings") ; Copy the login link here.


$test1 = "example@yahoo.com" ; Email goes here
$test2 = "Buddy" ; Passcode goes here

Local $username = _IEGetObjByName ($oIE, "email") ;(left click object and inspect) Use F12 on Chrome to get username
local $password = _IEGetObjByName ($oIE, "pass")  ;(left click object and inspect) Use F12 on Chrome to get password
local $button = _IEGetObjByName ($oIE, "u_0_x")   ;(left click object and inspect) Use F12 on Chrome to get button

_IEFormElementSetValue ($username, $test1)
_IEFormElementSetValue ($password, $test2)

$oBtn = _IEGetObjById($oIE, "u_0_x")
$oBtn = _IEGetObjById($oIE, "u_0_2")

_IEAction($oBtn, "click")

;;=======================END====================================================;;
;;===============================WEBPAGE========================================;;
;;=======================================CODE===================================;;
;;==============================================================================;;

While 1
    WinSetTitle($hMain, "", _IEPropertyGet($oIE, "title"))
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd


Func Terminate()
    Exit
EndFunc   ;==>Terminate

 

Edited by aa2zz6

Share this post


Link to post
Share on other sites

Hi, aa2zz6 and mLipok

Thank you for replying.

I have problem finding the correct ID from the DOM Tree.

I have tried to place all possible ID but it does not work.

Share this post


Link to post
Share on other sites

Here is the full copy of the DOM tree.

If someone can have a crack with it, you are most welcome.

Chrome_Browser_SSS_Login_Element2.jpg

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

OK, I have another crack on it, :):):) I think I found the correct ID = login_username:D:D:D

Chrome_Browser_SSS_Login_Element3.jpg

Edited by wepee

Share this post


Link to post
Share on other sites

Ok, success!!! 

Next, How to MAXIMIZE the Internet Explorer???

By default it is running on Minimize mode. ^_^

See the picture below.

IE_Browser_SSS_Login_minimized.jpg

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Hello again,

I would like to thank again, to aa2zz6 and mLipok.

I did a search on the forum, and found some information about open up IE in maximized window

Here is the link: Create a browser window and maximize it

After play around it, through trial and error, I finally nailed it.

Below is the final product.

This code will automatically sign into IE, loads Synology Surveillance Station web page, 

with username and password, and auto click the Sign in button.

#include <IE.au3>


Call ("SignIn")

 

Func SignIn ()

Global $oIE = _IECreate ("http://192.168.1.251/sss")

   $oIE.Visible = 1
   $oIE.Left = 0
   $oIE.Top = 0
   $oIE.Width = @DesktopWidth
   $oIE.Height = @DesktopHeight

   Local $oIFrame = _IEGetObjById($oIE, 'login_iframe')
   Local $oUserName = _IEGetObjById($oIFrame, "login_username") ; I suppouse that this ID is in one TD element above
   Local $oPassword = _IEGetObjById($oIFrame, "login_passwd")
   Local $oPressSignInButton = _IEGetObjById($oIFrame, "login-btn")

    _IEFormElementSetValue ($oUserName, "yourusername") ;your own actual username
    _IEFormElementSetValue ($oPassword, "yourpassword") ;your own actual password
    _IEAction ($oPressSignInButton, "click")

    EndFunc

 

Edited by wepee

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Hello All,

I have no or limited knowledge about programming stuff.

This is a continuation of what I did last year 2015.  I am writing to this post again because I have discovered

something new, that I have never discovered before back in Dec 2015.

My script that was contributed by forum members, unfortunately, it is infected with Malware.

Please see the attached pdf files, where I submitted the script to Virustotal to check for virus.

I have attached the script below. I hope someone can inform me whether my script is

CLEAN or False Positive or Malware.

The reason, I am asking for help here, is my antivirus vendor has rejected my request to investigate

my script, since I created by myself although I have submitted the file to them.

Thank you.

 

Automatically_Open_up_IE_create_SynoSurvStation_login.exe

VirusTotal_Scan_Result-Automatically_Open_up_IE_create_SynoStation_login.exe1.pdf

VirusTotal_Scan_Result-Automatically_Open_up_IE_create_SynoStation_login.exe2.pdf

VirusTotal_Scan_Result-Automatically_Open_up_IE_create_SynoStation_login.exe3.pdf

VirusTotal_Scan_Result-Automatically_Open_up_IE_create_SynoStation_login.exe4.pdf

Auto_Open_up_IE_create_sss_login.au3

Edited by wepee

Share this post


Link to post
Share on other sites

It is not infected ,  just choose the "false positive" option. Also check this topic :

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now