Jump to content

IE snippet help


Recommended Posts

http://quadryders.com/phpcc/snippet.php?sid=84

This snippet does not work...

I get an error:

C:\\HotMailSendMessage.au3 (28) : ==> Variable used without being declared.:

_IEAction($o_NewMessage, "click")

_IEAction(^ ERROR

I'm afraid I don't undertand this whole statement:

$o_Links = _IELinkGetCollection($o_IE)
     For $o_Link In $o_Links
          If $o_Link.tabIndex = 1 Then
               $o_NewMessage = $o_Link
                  
               ExitLoop
          EndIf
     Next
 
     If Not IsObj($o_NewMessage) Then Exit
 
     _IEAction($o_NewMessage, "click")
     _IELoadWait($o_IE)
Link to comment
Share on other sites

Place this at the top of your code and watch the SciTe console... it will help you debug:

#AutoIt3Wrapper_run_debug_mode=Y

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

  • Moderators

What a nasty site to automate. This works for classic view...

#include <IE.au3>

_HotmailSendMessage("your-email@hotmail.com", "yourpassword", "someone@somewhere.com", "Test Subject", "Test Message")

;===============================================================================
;
; Function Name:   _HotmailSendMessage
; Description:      Send a message using your hotmail account
; Parameter(s):     $s_Email - Your hotmail account name
;                   $s_Password - Your hotmail account password
;                   $s_To - The recipient of the message
;                   $s_Subject - The subject of the message
;                   $s_Body - The body of the message
; Requirement(s):   You must use classic view
; Return Value(s):
; Author(s):    big_daddy
;
;===============================================================================
;
Func _HotmailSendMessage($s_Email, $s_Password, $s_To, $s_Subject, $s_Body)
    $o_IE = _IECreate("http://hotmail.com", 0, 1)
    _IELinkClickByText($o_IE, "Sign in with a different account")
    $o_Form = _IEFormGetObjByName($o_IE, "f1")
    $o_Name = _IEFormElementGetObjByName($o_Form, "login")
    $o_Pass = _IEFormElementGetObjByName($o_Form, "passwd")

    _IEFormElementSetValue($o_Name, $s_Email)
    _IEFormElementSetValue($o_Pass, $s_Password)
    _IEFormSubmit($o_Form, 0)
    _IELoadWait($o_IE, 500)

    If StringInStr(_IEBodyReadText($o_IE), "Please try again") Then
        MsgBox(0, "Error", "The e-mail address or password is incorrect.")
        Return 0
    EndIf

    _IEImgClick($o_IE, "i_newmessage_2.gif")
    _IELinkClickByText($o_IE, "Show plain text")

    $o_Form = _IEFormGetObjByName($o_IE, "aspnetForm")
    $o_To = _IEFormElementGetObjByName($o_Form, "fTo")
    $o_Subject = _IEFormElementGetObjByName($o_Form, "fSubject")
    $o_Body = _IEGetObjByName($o_IE, "fMessageBody")

    _IEFormElementSetValue($o_To, $s_To)
    _IEFormElementSetValue($o_Subject, $s_Subject)
    $o_Body.Value = $s_Body

    _IEImgClick($o_IE, "i_send.gif")
    _IELinkClickByText($o_IE, "Sign out")
    _IEQuit($o_IE)

EndFunc   ;==>_HotmailSendMessage
Edited by big_daddy
Link to comment
Share on other sites

Could it be I dont have the right IE.au3

--> IE.au3 V2.3-1 Warning from function _IELinkClickByText, $_IEStatus_NoMatch
--> IE.au3 V2.3-1 Warning from function _IEFormGetObjByName, $_IEStatus_NoMatch
--> IE.au3 V2.3-1 Error from function _IEFormElementGetObjByName, $_IEStatus_InvalidDataType
--> IE.au3 V2.3-1 Error from function _IEFormElementGetObjByName, $_IEStatus_InvalidDataType
--> IE.au3 V2.3-1 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType
--> IE.au3 V2.3-1 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType
--> IE.au3 V2.3-1 Error from function _IEFormSubmit, $_IEStatus_InvalidDataType
--> IE.au3 V2.3-1 Warning from function _IEImgClick, $_IEStatus_NoMatch
--> IE.au3 V2.3-1 Warning from function _IELinkClickByText, $_IEStatus_NoMatch
--> IE.au3 V2.3-1 Warning from function _IEFormGetObjByName, $_IEStatus_NoMatch
--> IE.au3 V2.3-1 Error from function _IEFormElementGetObjByName, $_IEStatus_InvalidDataType
--> IE.au3 V2.3-1 Error from function _IEFormElementGetObjByName, $_IEStatus_InvalidDataType
--> IE.au3 V2.3-1 Warning from function _IEGetObjByName, $_IEStatus_NoMatch
--> IE.au3 V2.3-1 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType
--> IE.au3 V2.3-1 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType
--> IE.au3 V2.3-1 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType
--> IE.au3 V2.3-1 Warning from function _IEImgClick, $_IEStatus_NoMatch
--> IE.au3 V2.3-1 Warning from function _IELinkClickByText, $_IEStatus_NoMatch
Link to comment
Share on other sites

Nevermind that last one, it was the Classic View...

It works perfect.

$o_Form = _IEFormGetObjByName($o_IE, "f1")
    $o_Name = _IEFormElementGetObjByName($o_Form, "login")
    $o_Pass = _IEFormElementGetObjByName($o_Form, "passwd")

Are you getting the names of the objects by looking at the HTML source?

When I view the Gmail page source for instance, I don't see what I need...

_IELinkGetCollection($o_IE)
_IEImgGetCollection() 
_IELinkGetCollection() 
_IEFormElementGetCollection()

What's a good way to view the output of these commands when creating new IE code?

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