noseboy Posted March 2, 2007 Share Posted March 2, 2007 Gmail have an annoying habit of occasionally dumping legitimate posts into their spam folder. Currently, I manually go and move those into my Inbox every couple of weeks, but was looking to automate this. I can't get any of the click operations to work after I've submitted the logon form, whether it's to sign out of GMail or to click on the right buttons. Am I just doing something daft? I am a newbie to AutoIt so I suspect the answer is probably yes. All that happens is that I log on, I see the AutoIt icon for 20 seconds, and then it exits. Cheers #include <IE.au3> $oIE = _IECreate() _IENavigate($oIE, "http://mail.google.com") ; get pointers to the login form and username and password fields $o_form = _IEFormGetObjByName($oIE, "gaia_loginform") $o_login = _IEFormElementGetObjByName($o_form, "Email") $o_password = _IEFormElementGetObjByName($o_form, "Passwd") ; Set field values and submit the form _IEFormElementSetValue($o_login, "my user name") _IEFormElementSetValue($o_password, "my password") _IEFormSubmit($o_form) ; _IELoadWait($oIE) Sleep (20000) ;_IELinkClickByText($oIE, "Spam") ;_IELinkClickByText($oIE, "All") ;_IELinkClickByText($oIE, "Not Spam") _IELinkClickByText($oIE, "Sign out") Exit Link to comment Share on other sites More sharing options...
DaleHohm Posted March 2, 2007 Share Posted March 2, 2007 The resulting page uses Frames... You can examine the dynamically created page source with this: #include <IE.au3> $oIE = _IEAttach("Gmail - Inbox") ConsoleWrite(_IEDocReadHTML($oIE)) In here you'll find: <FRAMESET border=0 frameSpacing=0 rows=100%,* frameBorder=0 onload=lj()> <FRAME name=main src="?view=page&name=loading&ver=1q2chc66hnxek" frameBorder=0 noResize scrolling=no> <FRAME name=js src="?view=page&name=loading&ver=1q2chc66hnxek" frameBorder=0 noResize> </FRAMESET> Please read about the _IEFrame* functions. 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 More sharing options...
noseboy Posted March 2, 2007 Author Share Posted March 2, 2007 Please read about the _IEFrame* functions.Ah! Thanks very much Dale, that's exactly the pointer I needed.Cheers Link to comment Share on other sites More sharing options...
Jester009 Posted October 21, 2007 Share Posted October 21, 2007 I'm also trying to click 'Sign out' inside my gmail inbox. Still I haven't been able to do so Dale can you please shed some more light on the matter? Thanks Link to comment Share on other sites More sharing options...
DaleHohm Posted October 21, 2007 Share Posted October 21, 2007 In Gmail there is an iFrame inside a Frame... outer Frame is "main", iFrame name is "v1". Suggest you try DebugBar (see my sig) - it makes this very easy. 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 More sharing options...
Jester009 Posted October 21, 2007 Share Posted October 21, 2007 Hi Dale, Thanks a lot for the reply. And DebugBar is really useful. I was playing with it I can click 'sign out' now. This is the code section... $oFrame = _IEFrameGetObjByName ($oIE, "main") $oDiv = _IEGetObjByID($oFrame, "d_v1") $oIframe = _IEFrameGetObjByName ($oDiv, "v1") _IELinkClickByText($oIframe, "Sign out") _IEQuit($oIE) Now the problem is that the code would not proceed after '_IELinkClickByText' It keeps hanging there. Any idea what might be the cause? Also I wanted to click on settings as well. Its inside a <SPAN> tag. Trying to click it now. All the other links I can click using the above method. Thanks Jester009 Link to comment Share on other sites More sharing options...
weaponx Posted October 21, 2007 Share Posted October 21, 2007 First thing...maybe you should simply change your gmail spam settings so everything goes to your inbox.Second...why don't you enable pop3 in Gmail and then do all of your automation via Outlook or Firebird??http://mail.google.com/support/bin/answer....mp;answer=13273This would be much more reliable. Link to comment Share on other sites More sharing options...
HeffeD Posted October 21, 2007 Share Posted October 21, 2007 You can also set up filters that you could specify certain users always go to your inbox. Gmail's spam filter seems pretty good in my opinion, but I prefer POP3 access through Thunderbird. Link to comment Share on other sites More sharing options...
DaleHohm Posted October 23, 2007 Share Posted October 23, 2007 Now the problem is that the code would not proceed after '_IELinkClickByText' It keeps hanging there. Any idea what might be the cause?Try setting the wait parameter to 0 or False in _IELinkClickByText. Google does some inexpected things with AJAX that sometimes appear to create cross-site security issues - although they are not in the classic sense.Also I wanted to click on settings as well. Its inside a <SPAN> tag. Trying to click it now. All the other links I can click using the above method.Take a look at _IETagNameGetCollection and get a reference to the SPAN in question. You can then use _IEAction to click on it.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 More sharing options...
Jester009 Posted October 23, 2007 Share Posted October 23, 2007 Try setting the wait parameter to 0 or False in _IELinkClickByText. Google does some inexpected things with AJAX that sometimes appear to create cross-site security issues - although they are not in the classic sense. Tried that before. does not work. At my wits end now... Take a look at _IETagNameGetCollection and get a reference to the SPAN in question. You can then use _IEAction to click on it. Span problem is common to other links (compose mail, inbox, etc) This is the code I'm using. $oIE = _IEAttach("Gmail - Inbox") Sleep(1000) $oFrame = _IEFrameGetObjByName ($oIE, "main") $oDiv = _IEGetObjByID($oFrame, "d_v1") $oIframe = _IEFrameGetObjByName ($oDiv, "v1") $oSet1 = _IEGetObjByID($oIframe, "prf_g") $oSet = _IETagNameGetCollection($oSet1, "span") _IEAction($oSet, "click") MsgBox(0, "Extended", @extended) MsgBox(0, "Error", @error) Always get extended and error value as 0. I have really ran out solutions Link to comment Share on other sites More sharing options...
Blue_Drache Posted October 23, 2007 Share Posted October 23, 2007 (edited) You're trying to click an entire collection. $o_fRTBLinks = _IELinkGetCollection($oIE_RTB) $i_RTBNumLinks = @extended For $o_fRTBLink In $o_fRTBLinks If StringInStr($o_fRTBLink.href, "MbrSwitchServlet") > 0 Then $href_RTBLink = $o_fRTBLink.href ExitLoop EndIf Next _IENavigate($oIE_RTB, $href_RTBLink, 1) In my example, I match text in the href link to click the proper object, not the entire collection. Edit: Forgot the _IENavigate() Edited October 23, 2007 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
Jester009 Posted October 23, 2007 Share Posted October 23, 2007 (edited) Sorry my code should be like this $oIE = _IEAttach("Gmail - Inbox") Sleep(1000) $oFrame = _IEFrameGetObjByName ($oIE, "main") $oDiv = _IEGetObjByID($oFrame, "d_v1") $oIframe = _IEFrameGetObjByName ($oDiv, "v1") $oSet1 = _IEGetObjByID($oIframe, "prf_g") $oSet = _IETagNameGetCollection($oSet1, "span", 0) _IEAction($oSet, "click") MsgBox(0, "Extended", @extended) MsgBox(0, "Error", @error) I'm clicking by index. Another thing is I can't see a link for 'settings' Edited October 23, 2007 by Jester009 Link to comment Share on other sites More sharing options...
DaleHohm Posted October 23, 2007 Share Posted October 23, 2007 Please summarize your current situation... what have you accomplished and what are you still trying to do? 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 More sharing options...
Jester009 Posted October 23, 2007 Share Posted October 23, 2007 What I tried to do was to login to gmail and click on links like "sign out, compose mail, settings". Upto now I can login to gmail successfully. And I can click on 'sign out' I can't click on 'settings' and 'compose mail' links Link to comment Share on other sites More sharing options...
Blue_Drache Posted October 23, 2007 Share Posted October 23, 2007 is this your problem?; get pointers to the login form and username and password fields$o_form = _IEFormGetObjByName($oIE, "gaia_loginform")You keep talking about GMAIL, but your OP mentions GAIA. Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
Jester009 Posted October 23, 2007 Share Posted October 23, 2007 I can login to GMAIL without any problems. I'm having problem with these two lines $oSet = _IETagNameGetCollection($oSet1, "span", 0) _IEAction($oSet, "click") It won't click the what is inside the span tags. (i.e settings link) Link to comment Share on other sites More sharing options...
Blue_Drache Posted October 23, 2007 Share Posted October 23, 2007 That's odd, when I tried to scrape the screen, I got the "Javascript must be enabled to use Gmail in standard view." junk. :/ Switched to HTML view and used this code to get to the settings page. expandcollapse popup#include <IE.au3> $hwndFile = FileOpen(@TempDir & "\IETemp.txt", 2) If $hwndFile = -1 Then DBP("Blah", "File Creation Error", 80, 0) Exit 80 EndIf $oIE_Gmail = _IEAttach("Inbox") CrashRun($oIE_Gmail) $o_GLinks = _IELinkGetCollection($oIE_Gmail) For $o_GLink In $o_GLinks If StringInStr($o_GLink.href, "?v=prg") > 0 Then $href_GLink = $o_GLink.href ExitLoop EndIf Next _IENavigate($oIE_Gmail,$href_GLink) #region Function: Debugger #1: Displays HTML Func CrashRun($oIE, $i_flag = 0) ClipPut(_IEDocReadHTML($oIE)) If $i_flag = 0 Then FileWrite($hwndFile, _IEDocReadHTML($oIE)) FileClose($hwndFile) Run('Notepad "' & @TempDir & '\IETemp.txt"') Sleep(1000) FileDelete($hwndFile) EndIf EndFunc ;==>CrashRun #endregion #region Function: Debugger #2: Displays Console writes about errors with optional Message boxes. Func DBP($s_ver = "", $s_msg = "", $i_err = 0, $i_flag = 0) ; s_msg is the message displayed, $i_err is the error code ; $i_flag toggles messagebox display. Easily converts your debug notes into a custom errorhandler If $s_ver = "" Then $s_ver = "DBP: Error notification" If $s_msg = "" Then $s_msg = "Undefined message and/or error" $s_msg = "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & $s_msg ConsoleWrite($s_msg & " Error: " & $i_err & @LF) If $i_flag = 1 Then MsgBox(0x1010, $s_ver, $s_msg & @LF & "Error: " & $i_err) SetError($i_err) ; returns $i_err as @error EndFunc ;==>DBP #endregion Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
DaleHohm Posted October 23, 2007 Share Posted October 23, 2007 (edited) I must admit that I am rather puzzled about how the Settings element works. .focus and .click are not sufficient to activate it. There is something very creative being done that would take more research into the CSS and Javascript involved. In any case, this works. #include <IE.au3> $oIE = _IEAttach("Gmail - Inbox") $oFrame = _IEFrameGetObjByName ($oIE, "main") $oIframe = _IEFrameGetObjByName ($oFrame, "v1") $oSpan = _IETagNameGetCollection($oIframe, "span", 1) ; Get coordinates of Settings $x = _IEPropertyGet($oSpan, "screenx") $y = _IEPropertyGet($oSpan, "screeny") $w = _IEPropertyGet($oSpan, "width") $h = _IEPropertyGet($oSpan, "height") ; Move mouse to it and click MouseMove($x + $w/2, $y + $h/2) MouseClick( "", $x + $w/2, $y + $h/2) Dale Edited October 23, 2007 by DaleHohm 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 More sharing options...
Jester009 Posted October 25, 2007 Share Posted October 25, 2007 Thanks a lot for Blue_Drache and Dale. Seems can't do anything with the standard view on. Think basic html view is the way... Thanks again guys Link to comment Share on other sites More sharing options...
DaleHohm Posted October 25, 2007 Share Posted October 25, 2007 Thanks a lot for Blue_Drache and Dale.Seems can't do anything with the standard view on. Think basic html view is the way...Thanks again guysI'm puzzled by your last post. The example I wrote for you does what you asked for.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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now