Jump to content

Trying to use _IEAction to refresh Gmail


Herb191
 Share

Recommended Posts

I am trying to refresh my email page after I automatically login to Gmail. It will login fine but it doesn’t refresh the page after I’m logged in. I am sure I am just missing something simple but I cant seem to figure it out. Any help would be appreciated.

Thanks

#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, "login");
_IEFormElementSetValue($o_password, "pass")
_IEFormSubmit ($oForm, 0)
    

Sleep(60000)
$sMyString = "Refresh"
$oLinks = _IELinkGetCollection($oIE)

For $oLink in $oLinks
    $sLinkText = _IEPropertyGet($oLink, "innerText")
    If StringInStr($sLinkText, $sMyString) Then
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
Next
Link to comment
Share on other sites

I didnt see where you try to refresh.

You have to use something like:

_IEAction($oIE, "refresh")

If you want to refresh the $oLink object then you need to use:

_IEAction($oLink, "refresh") instead of _IEAction($oLink, "click")

Edited by Juvigy
Link to comment
Share on other sites

I thought I responded to this earlier as well... Just to let the OP know, the method he is trying to use with the below is generally good for clicking links.

For $oLink in $oLinks
    $sLinkText = _IEPropertyGet($oLink, "innerText")
    If StringInStr($sLinkText, $sMyString) Then
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
Next

Only that "Refresh" link in Gmail... Isn't a standard link... :D

SIGNATURE_0X800007D NOT FOUND

Link to comment
Share on other sites

Why to go for clicking the refresh link, when autoit has a function to do that using _IEAction() :D

Edited by Manjish
[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com
Link to comment
Share on other sites

I thought I responded to this earlier as well... Just to let the OP know, the method he is trying to use with the below is generally good for clicking links.

For $oLink in $oLinks
    $sLinkText = _IEPropertyGet($oLink, "innerText")
    If StringInStr($sLinkText, $sMyString) Then
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
Next

Only that "Refresh" link in Gmail... Isn't a standard link... :D

Is there a way to click on nonstandard links then?

I’m trying to learn how to do it this way because I would like the program to use the same method for opening an email in Gmail and extracting information from the body of the emails. (I’m just trying to learn more then one way to do things). It is also why I’m not using the _IEAction() function that refreshes.

There are a few post on this subject but none that I have posted and I try to read them all before posting. So I don’t think you are remembering responding to my post. None of the other post addressed my issue directly or at lest not in a way that I could understand (I am still learning),

Yes I read your post. I had been working on this program for over twelve hours and I went to bed after I posted. I apologize for not responding faster.

Any suggestions would help. Perhaps there is a better way to do the same thing? As long as I can extract info from incoming emails I will be happy.

Link to comment
Share on other sites

The statement I made about reading a post was directed towards Manjish, because he clearly did not read my post. I was letting you know, because you had stated you are in the process of learning, that the method you were using for clicking links was generally correct, Manjish skipped over the juicy bits, read it backwards or not at all and responded based on that knowledge...

As for getting that to work, Dale could probably write it in 30 seconds, so lets hope he stops by... As for me... I still have issues playing with more complex operations, so I look for a cheap way out... If your highly intent on using the "Refresh" button, rather than using _IEAction() <--- which would be a better way IMO, then switch your Default layout to "Basic HTML" as the screenshot below shows, and that link will become easily clickable using code you have already written.. :D

Posted Image

More information on the basic HTML layout...

http://mail.google.com/support/bin/answer.py?hl=en&answer=15049

Good Luck! :D

Edited by BinaryBrother

SIGNATURE_0X800007D NOT FOUND

Link to comment
Share on other sites

Well, the good news is you were right. I switched the layout to basic HTML and it work perfectly. The bad news is I’m still in the same boat…I had originally planned to use the senders name to open up the email from a particular person. The same way I am using the refresh link. Something like this:

$sMyString = "Amazon.com"
$oLinks = _IELinkGetCollection($oIE)

For $oLink in $oLinks
    $sLinkText = _IEPropertyGet($oLink, "innerText")
    If StringInStr($sLinkText, $sMyString) Then
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
Next

That would have worked fine in standard Gmail mode if it was a standard link. The problem is that in Gmails basic HTML layout you can only click on the subject line to open the email and not the senders name. Obviously the subject line will change from email to email…so back to the drawing board. Any suggestions…anyone?

Link to comment
Share on other sites

If you refresh the entire Gmail page, it would have to reload the entire interface, and that would be much less efficient than letting it refresh due to the refresh link.

The link is actually a div though. It doesn't have a unique ID on it, so you're stuck trying to find it some other way.

Well it does work in basic HTML but not in the standard Gmail mode. Which doesn’t really help me if I cant open up a new email after clicking the refresh link. Like you said each email has a unique ID so I have no way of opening an email up. It is just not working the way I had originally thought it would and I am now looking for help on how I can make it work…

Link to comment
Share on other sites

The statement I made about reading a post was directed towards Manjish, because he clearly did not read my post. I was letting you know, because you had stated you are in the process of learning, that the method you were using for clicking links was generally correct, Manjish skipped over the juicy bits, read it backwards or not at all and responded based on that knowledge...

My bad.. Didn't really get that you were implying the same thing.. Just pointed out the obvious and stressed on it!
[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com
Link to comment
Share on other sites

Ok so nobody has been able to help me out yet so I have been playing with some ideas that I thought might work:

I thought I might be able to use _IEDocReadHTML to look at the HTML and find out if there was a new email from a particular sender. If there was then I thought I would have the script examine the HTML to find the unique Http address for the email. Apparently I don’t know enough about HTML because I couldn’t figure out how it was generating the Http address. :D

Sooo I thought I would try to have the script examine the HTML for a particular sender and if it found the sender find the subject line from that sender. Then I thought I would use the subject line to open the email in the same way I am using the refresh link in to refresh the page.

Something like this:

$sMyString = "subject  line"
$oLinks = _IELinkGetCollection($oIE)

For $oLink in $oLinks
    $sLinkText = _IEPropertyGet($oLink, "innerText")
    If StringInStr($sLinkText, $sMyString) Then
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
Next

I really thought this would work and then I realized that even in Gmails basic HTML view mode the subject line is not a standard link. So I can’t open the email in this way…

Anyway I am still looking for some suggestions on how I might be able to open new emails after the page is refreshed. Does anyone have any ideas?

Link to comment
Share on other sites

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

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