Jump to content

login AND logout from hotmail


Recommended Posts

hi folks, i think i have a newbee question. but after two days of trying and searching i hope you can help me.

i want to login to hotmal live, wait a little while and logout. for the login i found a script, but i dont know how to access the "sign out" link.

i think i have to use the "IEFormElementGetCollection", but i dont understand how to use it. i think the form name is "aspnetForm" and the index is 44.

maybee can someone help me.

TIA

#include <IE.au3>

; Create a browser window and navigate to hotmail

$oIE = _IECreate ("http://www.hotmail.com")

; Get pointers to the login form and username, password, and signin fields

$o_form = _IEFormGetObjByName ($oIE, "f1")

$o_login = _IEFormElementGetObjByName ($o_form, "login")

$o_password = _IEFormElementGetObjByName ($o_form, "passwd")

$o_signin = _IEFormElementGetObjByName ($o_form, "SI")

$username = "username here"

$password = "password here"

; Set field values and submit the form

_IEFormElementSetValue ($o_login, $username)

_IEFormElementSetValue ($o_password, $password)

_IEAction ($o_signin, "click")

_IELoadWait ($oIE)

;sleep (5000)

;_IEImgClick ($oIE, ".NET Passport", "alt")

;$oform = _IEFormGetObjByName ($oIE, "aspnetForm")

$ologout = _IEFormElementGetCollection ("aspnetForm", 44)

_IEAction ($ologout, "click")

Exit

Link to comment
Share on other sites

thanks for your answer, but it don´t work for me. i try it with autoit quotes and nothing happens. i don´t want to use Mouseclick because it don´t work if you change the screen resolution. i have a working script for the classic hotmail but the problem is, that every time i change the resolution i have to change the coordinate. because of this i try to make a script with "IE.au3"

i think my problem is the understanding of forms, frames, elements and objects

if someone is interesting on my old script:

CODE
#Include <File.au3>

#Include <Array.au3>

#include <Process.au3>

#include <date.au3>

;----------------------------------------------------------------------

$PW="password here" ; Password

$DBPath="l:\mail\_db\Hotmail.ini" ; Pfad zur INI-Datei

$MaxLastLogin=14 ; max. Tage zwischen dem einloggen

$MailAnz=0 ; Anzahl Mailadressen

;----------------------------------------------------------------------

Dim $IniLine

;----------------------------------------------------------------------

_FileReadToArray($DBPath,$IniLine) ; File in Array einlesen

;----------------------------------------------------------------------

For $Nummer = 2 to UBound($IniLine) -1 ; erste Zeile auslassen -> INI-Section, -1 wegen Ubound

$text = StringSplit($Iniline[$Nummer], "=") ; Zeile auseinander nehmen

$MailName=$text[1] ; Teil vor "=" ist Mailadresse

$LastLogin=$text[2] ; Teil dahinter ist letztes Logindatum

$CountDays=_DateDiff( 'D',$LastLogin,_NowCalcDate()) ; Zeitdifferenz berechnen

If @error or $CountDays > $MaxLastLogin then ; wenn Fehler oder groesser "MaxLastLogin"-Tage, dann einloggen

;MsgBox(0, "Line read:", $MailName & " " & $LastLogin & " " & $CountDays)

$rc = _RunDos("start /MAX http://www.hotmail.com")

WinWaitSleep ("Anmelden - Mozilla Firefox", 4000)

SendWaitTab ($MailName, 500, 1) ; Mailadresse

SendWaitTab ($PW, 500, 2) ; Passwort

send ("{ENTER}")

$x=WinWait("MSN Hotmail - Heute - Mozilla Firefox","",5) ; Timeout 5 Sec.

if $x=1 then ; Account aktive

;MsgBox(0, "Alles erledigt", "Erfolgreich")

WinWaitSleepClick ("MSN Hotmail - Heute - Mozilla Firefox", 500, 415, 176) ; Seite - E-Mail

WinWaitSleep ("Willkommen bei MSN - Mozilla Firefox", 2500) ; Abmelden

IniWrite($DBPath, "Hotmail", $MailName, _NowCalcDate()) ; aktuelles Datum in Ini-Datei eintragen

Send("^w") ; Firefox schliessen

Sleep (1000)

else ; Account inaktiv

;MsgBox(0, "Alles erledigt", "Timeout")

WinWaitSleepClick ("MSN Hotmail - Ihr -Konto aktivieren - Mozilla Firefox", 500, 981, 457) ; wieder aktivieren

WinWaitSleepClick ("Nutzungsbedingungen - Mozilla Firefox", 1500, 599, 495) ; Ich stimme zu

WinWaitSleepClick ("Kostenlose Newsletter und Angebote - Mozilla Firefox", 1500, 524, 892) ; Newsletter

WinWaitSleepClick ("MSN Hotmail - Heute - Mozilla Firefox", 500, 415, 176) ; Seite - E-Mail

WinWaitSleep ("Willkommen bei MSN - Mozilla Firefox", 2500) ; Abmelden

IniWrite($DBPath, "Hotmail", $MailName, _NowCalcDate()) ; aktuelles Datum in Ini-Datei eintragen

Send("^w") ; Firefox schliessen

Sleep (1000)

endif

endif

next

MsgBox(0, "Alles erledigt", "Bei allen " & UBound($IniLine)-2 & " Accounts ist der letzte Login < " & $MaxLastLogin & " Tage")

;

;----------------------------------------------------------------------

; Functions

;----------------------------------------------------------------------

Func WinWaitSleep ($WTitle, $Pause)

WinWait ($WTitle)

WinActivate ($WTitle)

Sleep ($Pause)

EndFunc

;----------------------------------------------------------------------

Func WinWaitSleepClick ($WTitle, $Pause, $ClickX, $ClickY)

WinWait ($WTitle)

WinActivate ($WTitle)

Sleep ($Pause)

MouseClick("left", $ClickX, $ClickY)

Sleep (500)

EndFunc

;----------------------------------------------------------------------

Func SendWaitTab ($Text, $Pause, $TabAnz)

Sleep ($Pause)

send (StringStripCR($Text))

For $Anz=1 to $TabAnz

send ("{TAB}")

Next

Sleep ($Pause)

EndFunc

;----------------------------------------------------------------------

Func ClickSleep ($ClickX, $ClickY, $Pause)

MouseClick("left", $ClickX, $ClickY)

Sleep ($Pause)

EndFunc

;----------------------------------------------------------------------

Edited by MiHu
Link to comment
Share on other sites

Turns out that "Sign out" is just a link, not a form element:

_IELinkClickByText($oIE, "Sign out")

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

thanks, thats it. i tried it yesterday, but the problem is, that the site need too much time. with the sleep command it runs.

not the best way. but for the moment it works

thanks again

CODE
#include <IE.au3>

; Create a browser window and navigate to hotmail

$oIE = _IECreate ("http://www.hotmail.com")

; Get pointers to the login form and username, password, and signin fields

$o_form = _IEFormGetObjByName ($oIE, "f1")

$o_login = _IEFormElementGetObjByName ($o_form, "login")

$o_password = _IEFormElementGetObjByName ($o_form, "passwd")

$o_signin = _IEFormElementGetObjByName ($o_form, "SI")

$username = "xxxxxxx"

$password = "xxxxxxxx"

; Set field values and submit the form

_IEFormElementSetValue ($o_login, $username)

_IEFormElementSetValue ($o_password, $password)

_IEAction ($o_signin, "click")

_IELoadWait ($oIE)

sleep (10000)

;_IEImgClick ($oIE, ".NET Passport", "alt")

_IELinkClickByText($oIE, "Abmelden")

Exit

Edited by MiHu
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...