Jump to content

Trying to use _IEAction to refresh Gmail


Herb191
 Share

Recommended Posts

DOM access for this is a little tricky because there are 4 iFrames and none of them have names.

Take a look at this and see if you have questions:

#include <IE.au3>

$oIE = _IEAttach("Gmail - Inbox")
$oFrame = _IEFrameGetCollection($oIE, 3) ; you want 4th iFrame
;   alternate method:
;       $oFrame = $oIE.document.parentwindow.frames("canvas_frame")
$oDivs = _IETagnameGetCollection($oFrame, "div")
For $oDiv in $oDivs
    If String(_IEPropertyGet($oDiv, "innerhtml")) = "Refresh" Then
        _IEAction($oDiv, "click")
        ExitLoop
    EndIf
Next

Dale

I tried running it but nothing seemed to happen. It just opened up my email and quit. I must not quite understand what’s happening.

Here is what I ran:

#Include <Constants.au3>
#Include <IE.au3>


$oIE = _IECreate ("http://mail.google.com")
$oForm = _IEFormGetObjByName($oIE, "gaia_loginform")
$o_login = _IEFormElementGetObjByName ($oForm, "Email")
$o_password = _IEFormElementGetObjByName ($oForm, "passwd")

_IEFormElementSetValue($o_login, "my email");
_IEFormElementSetValue($o_password, "my pass")
_IEFormSubmit ($oForm, 0)
    
Sleep (15000)

$oIE = _IEAttach("Gmail - Inbox")
$oFrame = _IEFrameGetCollection($oIE, 3) ; I also tired the alternate method: $oFrame = $oIE.document.parentwindow.frames("canvas_frame")
$oDivs = _IETagnameGetCollection($oFrame, "div")
For $oDiv in $oDivs
    If String(_IEPropertyGet($oDiv, "innerhtml")) = "Refresh" Then
        _IEAction($oDiv, "click")
        ExitLoop
    EndIf
Next
Link to comment
Share on other sites

The code I wrote relied on having gmail up and running on the screen already - sorry I wasn't clear. You won't need the _IEAttach, however, if you get gmail on the screen and run my code you should see that it clicks the Refresh "link" (make certain you are in the standard interface and not the simple HTML interface). Is this not what you wanted?

Dale

P.S. Also, if you say it does "nothing" please still try to supply detail... what messages are sent to the SciTe console?

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

The code I wrote relied on having gmail up and running on the screen already - sorry I wasn't clear. You won't need the _IEAttach, however, if you get gmail on the screen and run my code you should see that it clicks the Refresh "link" (make certain you are in the standard interface and not the simple HTML interface). Is this not what you wanted?

Dale

P.S. Also, if you say it does "nothing" please still try to supply detail... what messages are sent to the SciTe console?

Ok I got it to work now. Yes it is what I wanted but I am not sure if it will work the way I want.

This is exactly what I want to be able to do:

Step 1. Continuality run and refresh my Gmail in the background.

Step 2. Check for emails from a sender or senders.

Step 3. If an email is received save the email or extract the need information from the email.

Step 4. Use information from the email in the rest of my program .

I figured if I could get the script to click on the refresh link I could use the same process to click on the senders name and open the email. From there I think I can get the information I need out of the email. The problem I am running into is I can’t seem to find a way to open up the email. The code you wrote wont work to click on the senders name right? And if it does can it do it with out showing the website? I am trying to design this program to run all the time with out interfering with what ever the user is doing at the time. Do you have any suggestions or know of a better way of going about it? I have been trying to get this to work for days now with no luck.

Link to comment
Share on other sites

It is all certainly possible, but this is not the easiest site to automate. Here is a formatted section of data taken from the new mail listing:

<TABLE id=:oz class="F cf zt" cellPadding=0 closure_hashCode_g6jbsg="316">
<TBODY closure_hashCode_g6jbsg="317">
    <TR id=:oy class="zA zE" closure_hashCode_g6jbsg="318">
        <TD style="CURSOR: url('images/2/openhand.cur'), default !important" id=:ox class="yUGic-PTfAse DulQLd">
            <IMG style="TOP: 5px" class=yUGic-Z2Tekc alt="" src="http://mail.google.com/mail/images/cleardot.gif">
            <INPUT id=:ow class=yUGic-VPt1j aria-labelledby="" type=checkbox>
        </TD>
        <TD class="y4 DulQLd">
            <IMG id=:ov class=zG alt="" src="http://mail.google.com/mail/images/cleardot.gif">
        </TD>
        <TD class="yX DulQLd" closure_hashCode_g6jbsg="319">
            <DIV id=:ou class=yW closure_hashCode_g6jbsg="320">
                <SPAN class=zF closure_hashCode_g6jbsg="311" email="direct@adobesystems.com">Adobe News Flash Newslet.</SPAN>
            </DIV>
        </TD>
        <TD class=DulQLd><B>»</B>&nbsp;</TD>
        <TD id=:ot class=DulQLd role=link tabIndex=0>
            <DIV class=xS>
            <DIV class=xT>
            <DIV class=y6><SPAN id=:or><B>September News Flash: Are you ready for Max 2009?</B></SPAN>?
            <SPAN class=y2>&nbsp;-&nbsp;News Flash: The monthly newsletter for Flash Platform developers. If this message is not …</SPAN></DIV></DIV></DIV>
        </TD>
        <TD class="yf DulQLd">&nbsp;</TD>
        <TD class="xW DulQLd">
            <SPAN id=:oq title="Fri, Sep 4, 2009 at 11:50 AM"><B>Sep 4</B></SPAN>
        </TD>
    </TR>

You'll see that the element IDs and CLASS specifications appear to be obfuscated... makes it harder to read, but some of the key pieces appear to be consistent, so you should still be able to do this.

Note that the ID of the table containing the messages has an ID of ":oz". I logged into another system and checked and this appears to be consistent. Each of the TR table rows in that table contain an email message... each TR is split into TD elements that contain unique email message data. So you can drill in and split it apart and get what you need.

None of these are traditional "links" and instead are driven by associated Javascript activated by events on the elements (like onclick). Depending on what you need to do, you may have to drill into and understand the Javascript code behind it all. If you're not using a tool like DebugBar or the IE8 Developer Tools (part of IE8) you are making all of this way too hard.

If this is your first attempt at a project like this, you may want to go try to automate some other websites first and then bring your learnings back to this project. Also, as mentioned earlier, if there is a GMail API you may want to learn it instead in this case.

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

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