srnetwork Posted February 3, 2019 Share Posted February 3, 2019 Hello friends, I'm new to the community and I'm not a language expert yet, but I'm in need of help because I have several requests to create scripts for various websites (http and https) to automate the login, so I enter the command with the user and password, and the script will open the browser with the parameters I put in the comment (eg sample.exe username =% u password =% p). Could someone help me with a template type that I could fit for each need and if possible describe to me what adjustments I should observe when appropriate for each website? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 3, 2019 Moderators Share Posted February 3, 2019 Moved to the appropriate forum. Moderation Team Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted February 3, 2019 Moderators Share Posted February 3, 2019 @srnetwork It depends on your browser of choice. If you are using Chrome, check out the Chrome UDF in the Examples forum. If IE, take a look at _IECreate in the help file to get you started. Remember that the help file is your friend; just about every one of the _IE functions will have at least one if not more examples on how to do it. Try some things out on your own; if you get stuck, post your code here and we will do our best to assist. "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 More sharing options...
srnetwork Posted February 4, 2019 Author Share Posted February 4, 2019 Thanks very much JLogan3o13 for the help and I'm using an example posted by a friend in the Forum, but I wanted the user and password to be parameters that I inserted along with the execution of the script. About the browser, I have no restriction so far and for now how much simpler better =======================sample======================= #include <IE.au3> $Url = 'https://www.linkedin.com/uas/login?_l=pt' $User = 'username' $Pwd = 'password' $test = _IEAutoLogin($Url, $User, $Pwd) Func _IEAutoLogin($sUrl, $sUsername, $sPwd) ;funkey 09.09.09 $oIE = _IECreate($sUrl) _IEErrorNotify(False) _IEErrorHandlerRegister() $oForms = _IEFormGetCollection($oIE) If @error Then Return SetError(1, _IEErrorHandlerDeRegister(), $oIE) ;'no forms --> no login' Else $Index = 0 For $oForm In $oForms $oFormElements = _IEFormElementGetCollection($oForm) If IsObj($oFormElements) Then $IndexElement = 0 For $oElement In $oFormElements If $oElement.Type = 'password' Then $oPwd = _IEFormElementGetObjByName($oForm, $oElement.Name) _IEFormElementSetValue($oPwd, $sPwd) For $i = $IndexElement - 1 To 0 Step -1 $oUser = _IEFormElementGetCollection($oForm, $i) If $oUser.Type = 'text' Then _IEFormElementSetValue($oUser, $sUsername) ExitLoop EndIf Next If $oForm.action <> "0" And Not StringInStr($oForm.action, '.php') Then ;submit _IEFormSubmit($oForm, 0) _IELoadWait($oIE) Else ;click For $i = $IndexElement + 1 To $IndexElement + 10 ;check the next 10 elements $oButton = _IEFormElementGetCollection($oForm, $i) If $oButton.Type = 'submit' Then _IEAction($oButton, "click") ExitLoop EndIf Next EndIf Return SetExtended(_IEErrorHandlerDeRegister(), $oIE) EndIf $IndexElement += 1 Next EndIf $Index += 1 Next EndIf Return SetError(2, _IEErrorHandlerDeRegister(), $oIE) ;no password-field found EndFunc ;==>_IEAutoLogin ===================== Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now