Jump to content

autoit autologin


Pere
 Share

Recommended Posts

Hi all,

I've written the script below to automatically login to a website, in this case infusionsoft.com

The auto login works fine. Is there a way for me to get errors from Internet explorer, if the login fails because of wrong login credentials. I have searched around, but cannot make sense of this.

Please forgive me if I have overlooked something simple. I am new to autoit. Please see my script below.

#include <IE.au3>
#include <MsgBoxConstants.au3>


Func AccountAutoLogin()

   ;This line sets the website page to open and inject information
   Global $oIE = _IECreate("https://signin.infusionsoft.com/login")

   ;set the variables to pull the username and password object names
   Local $username = _IEGetObjByName ($oIE, "username")
   Local $password = _IEGetObjByName ($oIE, "password")

   ;set the $oButtons variable to pull all the values of the button class
   Local $oButtons = _IETagnameGetCollection($oIE, "button")

   ;set the username and password values on the login form
   _IEFormElementSetValue ($username, "")
   _IEFormElementSetValue ($password, "")

   ; loop through the button class until we find the text on the login button, then click the button
   For $oButton in $oButtons
      If String($oButton.value) = " Log In " Then $test = $oButtons
         _IEAction($oButton, "click")
         _IELoadWait($oIE)
         if (@error) then MsgBox (0, "Error", @error)
      ExitLoop
   Next

EndFunc

Link to comment
Share on other sites

Welcome to AutoIt and the forum!

How could you enter wrong credentials when they are provided by your script?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

There is going to be some element that is presented to the user stating that the credentials didn't work...you'd have to look for the web element displaying that message, and grab the text.

Maybe expect to find a logout button/link, and if not found within a couple seconds, look for the failure elements.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
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
 Share

×
×
  • Create New...