Jump to content

Recommended Posts

Posted (edited)

This is a script for automatic login on websites using the Internet Explorer

#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

Have fun!

Tell me, if there are any sites you could not log in. Thank you.

Edit: Better version of the script should work on far more websites.

Edited by funkey

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Posted

thank you for this script but

ı need only user no password inthe site

exam

site

then

send "aaratratarata" enter

like it

this code hospital appointment record

#include <IE.au3>

$Url = 'http://www.fffffffffffffffffffffffff.html

$oIE = _IECreate($Url)

sleep(200)

Send("0000000000000") "user number" ?????

sleep(20)

Send("{ENTER}")thank you help me

Posted

New version of my script in post#1.

It should now work on far more websites. Tell me, if there are any sites you could not log in. Thank you.

mesale0077: Without link I can't help you.

Also remember: This is not a general support forum! :D

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Posted

This is a script for automatic login on websites using the Internet Explorer

#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

Have fun!

Tell me, if there are any sites you could not log in. Thank you.

Edit: Better version of the script should work on far more websites.

Nice job... What about a version working with Mozilla Firefox ?

FreeRiderHonour & Fidelity

  • 2 months later...
Posted

This function needs a lot of improvement. When I have time I will do it.

@Cowhead : Do you have an url with activex login for testing?

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

  • 1 year later...
Posted

Thanks man!

That was what I needed. I wanted something like that for our Outlook Webmail for work. All I had to change was the web address and user/password. I prefer Firefox, but this is fine :huh2:

This is a script for automatic login on websites using the Internet Explorer

#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

Have fun!

Tell me, if there are any sites you could not log in. Thank you.

Edit: Better version of the script should work on far more websites.

  • 5 months later...
Posted

You fail at forums. Go away. Things you've done wrong:
  • Used the report feature in an attempt to post to this thread.
  • You didn't read the rules before posting or you would see that discussion of auto-login methods is not allowed (this thread was created before that rule and hasn't been locked as a result).
  • You revived an old thread.
Thread locked. Now leave and don't come back.
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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