Jump to content
Sign in to follow this  
okimomale

Automatic website login and logout

Recommended Posts

okimomale

Hi ....

I recently fould an autoit script that works well with auto logging me into a website.  What the script doesn't do is log me back out afterwards.  I was hoping there is someone here who could tweek this script a little so that after it logs on, it will wait 5 seconds or so, then log the user back out and ending the script.  This is a site that requires free users to login atleast every 30 days or loose their account. 

#include <IE.au3>

$Url = 'https://www.noip.com/login/'
$User = 'xxxxx'
$Pwd = 'xxxxxxxxx'

$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

Any help would be greatly appreciated.

Okimomale

Share this post


Link to post
Share on other sites
lolipop

I don't think automation of sites login is allowed for discussion here.

Forum Rules

Share this post


Link to post
Share on other sites
okimomale

Actually I was asking about logging out of a site, not site login.

I don't think automation of sites login is allowed for discussion here.

Forum Rules

Share this post


Link to post
Share on other sites
Mobius

In or out does not matter sorry.

Share this post


Link to post
Share on other sites
okimomale

Hey, then by all means delete the post.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×