Jump to content
Sign in to follow this  
carloselectro

Help with IE.au3

Recommended Posts

carloselectro

Could someone help me with this script?

It's working for the gmail webpage but not evernote..

I can see it's entering the user and password corectly but it does not click the Connexion button...

The webpage is in french but I do not think it matters.

#include <IE.au3>

$Url = 'https://www.evernote.com/Login.action?targetUrl=/Home.action'
$User = 'XXXXX'
$Pwd = 'XXXXX'

$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

Share this post


Link to post
Share on other sites
jfcby

Try this...

#include <IE.au3> 

$sURL = "https://www.evernote.com/Login.action?targetUrl=/Home.action" 
$sLogin = "username" 
$sPassword = "*******" 
$oIE = _IECreate($sURL) 
$oFormLogin = _IEFormGetObjByName($oIE, "login_form") 
$oLogin = _IEFormElementGetObjByName($oFormLogin, "username") 
$oPassword = _IEFormElementGetObjByName($oFormLogin, "password") 
_IEFormElementSetValue($oLogin, $sLogin) 
_IEFormElementSetValue($oPassword, $sPassword)

_IEFormSubmit ($oFormLogin)

jfcby


Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB ****

Share this post


Link to post
Share on other sites
carloselectro

I have tried your code and still have the same problem...

Share this post


Link to post
Share on other sites
jfcby

I tested the code on the English version of the website it inserts the username, password, and clicks the login button.

I'm not sure what else to tell you. May someone else can test it for you on the French version of the website.

jfcby

Edited by jfcby

Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB ****

Share this post


Link to post
Share on other sites
jfcby

carloselectro,

I kept working with your orginial script and this modified script does login into evernote.com.

#include <IE.au3>

$Url = 'https://www.evernote.com/Login.action?targetUrl=/Home.action' ;<<< Change URL
$User = 'username' ;<<< Change username
$Pwd = 'password' ;<<< Change 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)
    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
      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

jfcby


Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB ****

Share this post


Link to post
Share on other sites
carloselectro

It's working now.Thanx a lot jfcby!

carloselectro,

I kept working with your orginial script and this modified script does login into evernote.com.

#include <IE.au3>

$Url = 'https://www.evernote.com/Login.action?targetUrl=/Home.action' ;<<< Change URL
$User = 'username' ;<<< Change username
$Pwd = 'password' ;<<< Change 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)
    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
      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

jfcby

Share this post


Link to post
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
Sign in to follow this  

×