Jump to content

Gmail login


Recommended Posts

Hi,

I was using the below Gmail script that used to login to my Gmail and password automatically using IE. After the new type of login method in Gmail. I am not able to do it using the below code.
Has anyone tried on the auto login script for Gmail for latest Gmail login method?

Global $oIE =_IECreate ("https://accounts.google.com/ServiceLogin?sacu=1&continue=http%3A%2F%2Fmail.google.com%2Fmail%2F%3Fpc%3Dtopnav-about-en&hl=en&service=mail")

    local $username = _IEGetObjByName ($oIE, "Email")
    Local $password = _IEGetObjByName ($oIE, "Passwd")

    Local $Email_button = _IEGetObjByName ($oIE, "Email")
    Local $Signin_button = _IEGetObjByName ($oIE,"signIn")

    _IEFormElementSetValue ($username, "mygmailaddress@gmail.com")     
    _IEFormElementSetValue ($password, "mygmailpassword")               

    _IEAction ($Email_button, "click")
    _IEAction ($Signin_button, "click")

 

if so can someone help me with this?

Thanks!

Link to comment
Share on other sites

This should work fine:

#include <IE.au3>

$sEmail = 'myemail'
$sPassword = 'mypassword'

$oIE = _IECreate('https://gmail.com')
GMailSubmitFormElement($oIE,'identifier',$sEmail)
GMailSubmitFormElement($oIE,'password',$sPassword)

Sleep(10000)

_IEQuit($oIE)

Func GMailSubmitFormElement($oIE,$sElement,$sValue,$iTimeout=10, $iDelay=1)
    $Timer = TimerInit()
    Do
        $oForm = _IEFormGetCollection($oIE,0)
        $oElement = _IEFormElementGetObjByName($oForm,$sElement)
        Sleep($iDelay * 1000)
    Until IsObj($oElement) Or TimerDiff($Timer) >= $iTimeout * 1000
    _IEFormElementSetValue($oElement,$sValue)
    $oViewContainer = _IEGetObjById($oIE,'view_container')
    $oSpans = _IETagNameGetCollection($oViewContainer,'span')
    For $oSpan In $oSpans
        If $oSpan.innerHTML = 'Next' Then
            _IEAction($oSpan,'click')
            ExitLoop
        EndIf
    Next
EndFunc

 

When the words fail... music speaks.

Link to comment
Share on other sites

  • 5 months later...

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