Jump to content

[Solved]Autologin not wroking for a specific page


Ignacio
 Share

Recommended Posts

Hi there, i have been using the autlogin script from this post https://www.autoitscript.com/forum/topic/102119-website-autologin-with-internet-explorer/

It works good, at least until i tried to login to my school student account (http://mictlantecuhtli.itmatamoros.edu.mx/), at first i thought it didnt log because you had to click a button first so the user and password forms appear (but that wanst the case, since other website that work in a similar fashion log just fine) the i checked the form names from the website, to see if where the same for the script values, and ideed they are, it doesnt even trigger the error options from the script. So i ran out of ideas to see resolve the problem, any help would be really appreciated.

code below in case no one wants to get sidetracked

Spoiler
#include <IE.au3>

$Url = 'http://www.autoitscript.com/forum/index.php?app=core&module=global&section=login'
$User = 'user'
$Pwd = 'pwd'

$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

 

 

Edited by Ignacio
Link to comment
Share on other sites

It may be because the login form is in a frame, pointing to the url: http://mictlantecuhtli.itmatamoros.edu.mx/acceso.php

if i check for number of forms detected ti says zero:

ConsoleWrite($oForms.Length&@CRLF)

So either you need to update the script to look within frames/iframes, or access the page directly.

If change the URL to acceso.php, I get:

Introduce un NIP numérico

Hope this solves your problem :)

Link to comment
Share on other sites

8 hours ago, genius257 said:

It may be because the login form is in a frame, pointing to the url: http://mictlantecuhtli.itmatamoros.edu.mx/acceso.php

if i check for number of forms detected ti says zero:

ConsoleWrite($oForms.Length&@CRLF)

So either you need to update the script to look within frames/iframes, or access the page directly.

If change the URL to acceso.php, I get:

Introduce un NIP numérico

Hope this solves your problem :)

I tried it whit the acceso.php url, and it does loginm but i think it clicks something else that i dont have access to, because a meessage from the website appears and kicks me out.

So i will check the frames/iframes as you suggested,  now i dont need to run blind with the script.

Thanks for kind the answer (n.n)/

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...