Jump to content

AutoIT Automation for Excel list user & password login


Recommended Posts

Hi to all expert, I need to create an automation login a website with the given username and password. After login I need to automate some task in there and then logout and then login other username and password with complete the task until the list in excel is over. How do I create an automation with the loop login username & password while complete the task aswell. I know there might be other thread but I hope I can get the answer or redirect me to the right place. thank you 

image.png.5c55990c53779fb9e924efe156d351ac.png

 

; Create a browser window and navigate to Australia Post
$oIE = _IECreate("https://mylocalsample.com/login/")
$hwndIE = _IEPropertyGet ($oIE, "hwnd")
WinSetState($hwndIE, "", @SW_MAXIMIZE)
; get pointers to the login form and username, password and signin fields
Local $o_form = _IEFormGetObjByName($oIE, "mblogin")
Local $o_login = _IEFormElementGetObjByName($o_form, "userid")
Local $o_password = _IEFormElementGetObjByName($o_form, "password")
Local $username = "Paul"
Local $password = "ps4123"
; Set field values and submit the form
_IEFormElementSetValue($o_login, $username)
_IEFormElementSetValue($o_password, $password)
;_Submit login
_IEFormSubmit($o_form)
;Click the Manifest Link
_IENavigate($oIE, "https://mylocalsample.com/login/generateManifest/")
Sleep(1000)
;
;
;Select Manifest BRISBANE
Local $o_manifest = _IEGetObjByID($oIE, "manifest")
_IEAction($o_manifest, "focus")
_IEAction($o_manifest, "selectall")
ClipPut ("Direct Entry Australia")
_IEAction($o_manifest, "paste")
;_IEAction($o_manifestStartDate, "focus")Minus 30Days
Local $o_manifestStartDate = _IEGetObjByID($oIE, "manifestStartDate")
Local $oAppl = _Excel_Open()
Local $oMyDocDir = @MyDocumentsDir & "\Date.xlsx"
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example", "Error Copy Date" & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open Workbook 1
Local $oWorkbook1 = _Excel_BookOpen($oAppl, $oMyDocDir, True)
Local $oRange = $oWorkbook1.ActiveSheet.Range("A4")
_Excel_RangeCopyPaste($oWorkbook1.ActiveSheet, $oRange) ;paste it to program like notepad, wordpad, DMS, or msword
;WinActivate("New Zealand Post - Customs Manifests - Internet Explorer", "")
_IEAction($o_manifestStartDate, "focus")
_IEAction($o_manifest, "selectall")
_IEAction($o_manifestStartDate, "paste")
;_IEAction($o_manifestEndDate, "focus")Today
Local $o_manifestEndDate = _IEGetObjByID($oIE, "manifestEndDate")
_IEAction($o_manifestEndDate, "focus")
Sleep(1000)
Local $o_manifestPort = _IEGetObjByID($oIE, "manifestPort")
_IEAction($o_manifestPort, "focus")
_IEAction($o_manifestPort, "selectall")
ClipPut ("Brisbane")
_IEAction($o_manifestPort, "paste")
Local $o_selectedManifestDate = _IEGetObjByID($oIE, "selectedManifestDate")
_IEAction($o_selectedManifestDate, "focus")
Sleep(1000)
Local $o_ConfirmManifest = _IEGetObjByID($oIE, "generateManifestButton")
_IEAction($o_ConfirmManifest, "focus")
_IEAction($o_ConfirmManifest, "click")
Sleep(1000)
Local $o_LodgementRef = _IEGetObjByID($oIE, "lodgementRef")
_IEAction($o_LodgementRef, "focus")
ClipPut ("BNE")
_IEAction($o_LodgementRef, "paste")
Local $o_ContinueM = _IEGetObjByID($oIE, "dijit_form_Button_0_label") ; dijit_form_Button_1_label cancel
_IEAction($o_ContinueM, "click")
sleep(1000)
;
;
;
;Logout
_IENavigate($oIE, "https://mylocalsample.com/login/?logout")
Sleep(1000)

Local $o_form = _IEFormGetObjByName($oIE, "mblogin")
Local $o_login = _IEFormElementGetObjByName($o_form, "userid")
Local $o_password = _IEFormElementGetObjByName($o_form, "password")
Local $username = "Raymond"
Local $password = "Overigh23"
; Set field values and submit the form
_IEFormElementSetValue($o_login, $username)
_IEFormElementSetValue($o_password, $password)
;_Submit login
_IEFormSubmit($o_form)
;Click the Manifest Link
_IENavigate($oIE, "https://mylocalsample.com/login/generateManifest/")
Sleep(1000)
;
;
;Select Manifest BRISBANE
Local $o_manifest = _IEGetObjByID($oIE, "manifest")
_IEAction($o_manifest, "focus")
_IEAction($o_manifest, "selectall")
ClipPut ("Direct Entry Australia")
_IEAction($o_manifest, "paste")
;_IEAction($o_manifestStartDate, "focus")Minus 30Days
Local $o_manifestStartDate = _IEGetObjByID($oIE, "manifestStartDate")
Local $oAppl = _Excel_Open()
Local $oMyDocDir = @MyDocumentsDir & "\Date.xlsx"
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example", "Error Copy Date" & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open Workbook 1
Local $oWorkbook1 = _Excel_BookOpen($oAppl, $oMyDocDir, True)
Local $oRange = $oWorkbook1.ActiveSheet.Range("A4")
_Excel_RangeCopyPaste($oWorkbook1.ActiveSheet, $oRange) ;paste it to program like notepad, wordpad, DMS, or msword
;WinActivate("New Zealand Post - Customs Manifests - Internet Explorer", "")
_IEAction($o_manifestStartDate, "focus")
_IEAction($o_manifest, "selectall")
_IEAction($o_manifestStartDate, "paste")
;_IEAction($o_manifestEndDate, "focus")Today
Local $o_manifestEndDate = _IEGetObjByID($oIE, "manifestEndDate")
_IEAction($o_manifestEndDate, "focus")
Sleep(1000)
Local $o_manifestPort = _IEGetObjByID($oIE, "manifestPort")
_IEAction($o_manifestPort, "focus")
_IEAction($o_manifestPort, "selectall")
ClipPut ("Brisbane")
_IEAction($o_manifestPort, "paste")
Local $o_selectedManifestDate = _IEGetObjByID($oIE, "selectedManifestDate")
_IEAction($o_selectedManifestDate, "focus")
Sleep(1000)
Local $o_ConfirmManifest = _IEGetObjByID($oIE, "generateManifestButton")
_IEAction($o_ConfirmManifest, "focus")
_IEAction($o_ConfirmManifest, "click")
Sleep(1000)
Local $o_LodgementRef = _IEGetObjByID($oIE, "lodgementRef")
_IEAction($o_LodgementRef, "focus")
ClipPut ("BNE")
_IEAction($o_LodgementRef, "paste")
Local $o_ContinueM = _IEGetObjByID($oIE, "dijit_form_Button_0_label") ; dijit_form_Button_1_label cancel
_IEAction($o_ContinueM, "click")
sleep(1000)
;
;Logout
_IENavigate($oIE, "https://mylocalsample.com/login/?logout")
Sleep(1000)
;
Spoiler
Spoiler

 

 

 

Edited by 9tailsfox
Revised
Link to comment
Share on other sites

Yes, I will. As you can see I just created very simple script but If it able to read the username and password in the excel column. In the future I just need to update the Excel list not the au3 script. 

 

 

 

Thank you :-)

Link to comment
Share on other sites

  • Moderators

Also, as a friendly reminder, please ensure you've read and are adhering to the forum rules when it comes to website automation. :)

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...