anixon Posted July 6, 2007 Author Share Posted July 6, 2007 Get the Form's object first. And post code that can actually be run: #include <IE.au3> $oIE = _IECreate("www.anz.com.au") _IELoadWait($oIE) $oForm = _IEFormGetObjByName($oIE, "login_form") If IsObj($oForm) Then _IEFormImageClick($oForm, "log on", "alt") Sleep(2000) MsgBox(64, "Message", "I think I clicked on logon...") Else MsgBox(16, "Message", 'Couldn not get "login_form" object.') EndIfoÝ÷ Ù8ZµØmÂä²-®'jëh×6 _IEFormImageClick($oForm, "/common/img/buttons/b2_logon.gif", "src")oÝ÷ Ù8ZµØmÂäz+azµ¡jÙuèÂäÁ«,Â+)à¶"h'$jëh×6#include <IE.au3> $oIE = _IECreate("www.anz.com.au") _IELoadWait($oIE) $oForm = _IEFormGetObjByName($oIE, "login_form") If IsObj($oForm) Then _IEImgClick($oForm, "/common/img/buttons/b2_logon.gif", "src") Sleep(2000) MsgBox(64, "Message", "I think I clicked on logon...") Else MsgBox(16, "Message", 'Couldn not get "login_form" object.') EndIfoÝ÷ Ùhbr¥²(®K0ØZºÚ"µÍWÒQR[YÐÛXÚÊ ÌÍÛÑÜK ][ÝÛÙÈÛ][ÝË ][ÝØ[ ][ÝÊ Problem solved... Thanks for the code unfortunately it does not work on my system Windows XP SP2. I get the "I think I clicked on logon.." message but it does not open "https://www.anz.com/inetbank/bankmain.asp" which is the result for clicking on this button. Ant.. Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 6, 2007 Share Posted July 6, 2007 (edited) Thanks for the code unfortunately it does not work on my system Windows XP SP2. I get the "I think I clicked on logon.." message but it does not open "https://www.anz.com/inetbank/bankmain.asp" which is the result for clicking on this button.Ant..Works fine for me in XP Pro SP2 With IE 6 SP2. Note that bankmain.asp page opens in a separate pop-up, which initially tripped the pop-up blocker until I allowed it, then I had to "OK" the warning dialog for opening a secure page.Your script will have to _IEAttach() to the new window to continue with the logon. And since the pop-up window doesn't have a toolbar - you'll have to use a script to get the source HTML and parse out the username/password/logon controls. Edited July 6, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
anixon Posted July 6, 2007 Author Share Posted July 6, 2007 (edited) Works fine for me in XP Pro SP2 With IE 6 SP2. Note that bankmain.asp page opens in a separate pop-up, which initially tripped the pop-up blocker until I allowed it, then I had to "OK" the warning dialog for opening a secure page.Your script will have to _IEAttach() to the new window to continue with the logon. And since the pop-up window doesn't have a toolbar - you'll have to use a script to get the source HTML and parse out the username/password/logon controls. Good news as I have made some progress. I am running IE7 with the Popup Blocker turned off. When I run the script I get this message "Popups were blocked on this page. Press "CTRL" key when checking to allow popups. There is no Popup task bar being displayed to click on and the bankmain.asp page does not open. However if I hold down the "CTRL" key for the whole time that the script runs then bankmain.asp will launch. If this is resolved with a IE7 setting then I am not aware of it.What do you think?Ant..Edit:I tracked down the "CTRL" problem to the Google Toolbar which was installed in IE7. If I am not mistaken it appears to have its own Popup Blocker functionality or at least overides the IE7 switched off settings. Anyway when I disabled it in Tools/'Add-ons the problem was resolved.So much to learn so little time now the next thing is to resolve the issue of passing the user name and password to bankmain.aspThanks for the help which has been very much appreciated.Ant.. Edited July 6, 2007 by anixon Link to comment Share on other sites More sharing options...
anixon Posted July 7, 2007 Author Share Posted July 7, 2007 (edited) Good news as I have made some progress. I am running IE7 with the Popup Blocker turned off. When I run the script I get this message "Popups were blocked on this page. Press "CTRL" key when checking to allow popups. There is no Popup task bar being displayed to click on and the bankmain.asp page does not open. However if I hold down the "CTRL" key for the whole time that the script runs then bankmain.asp will launch. If this is resolved with a IE7 setting then I am not aware of it.What do you think?Ant..Edit:I tracked down the "CTRL" problem to the Google Toolbar which was installed in IE7. If I am not mistaken it appears to have its own Popup Blocker functionality or at least overides the IE7 switched off settings. Anyway when I disabled it in Tools/'Add-ons the problem was resolved.So much to learn so little time now the next thing is to resolve the issue of passing the user name and password to bankmain.aspThanks for the help which has been very much appreciated.Ant..I think that I am attached to the correct page the consul write reports:<FRAME id=main hideFocus name=main src="login.asp?BOX=" frameBorder=0 noResize target="_top"><FRAME id=data hideFocus name=data src="hiddenframe.asp" frameBorder=0 noResize><NOFRAMES></NOFRAMES>I have not been able to find any forms on that page or pass data to the input boxes. I get this report--> IE.au3 Warning from function _IEFormGetObjByName, $_IEStatus_NoMatch--> IE.au3 Error from function _IEFormElementGetObjByName, $_IEStatus_InvalidDataType--> IE.au3 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataTypeThis is the code that does not workCODE#include <IE.au3>GLOBAL $oIEL = ""$oIE = _IECreate("www.anz.com.au")_IELoadWait($oIE)WinSetState("ANZ HomePage", "", @SW_MAXIMIZE)$oForm = _IEFormGetObjByName($oIE, "login_form")_IEImgClick($oForm, "log on", "alt")$oIEL = _IEAttach ("https://www.anz.com/inetbank/bankmain.asp", "url")If IsObj($oIEL) Then MsgBox(64, "Message", "I think I am attached")Else MsgBox(16, "Message", 'I am not attached')EndIfConsoleWrite(_IEBodyReadHTML($oIEL) & @CR)$oForm = _IEFormGetObjByName($oIEL, "document.loginForm")$oQuery = _IEFormElementGetObjByName($oForm, "USERID")_IEFormElementSetValue($oQuery, "Input")Help is always appreciatedAnt.. Edited July 7, 2007 by anixon Link to comment Share on other sites More sharing options...
DaleHohm Posted July 7, 2007 Share Posted July 7, 2007 Make certain that the ConsoleWrite is executed AFTER any redirects have completed. If the output does not include the same output as the View Source then there are two likely issues - 1) there are FRAMES or iFRAMES involved or 2) there is Javascript involved which is dynamically changing the HTML. In the case of 2), the output from the ConsoleWrite is more accurate for your purposes than View Source. Issue 1 is much more likely.DaleLooks like you need to learn about Frames. Please see _IEFrameGetObjByNameDale 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...
anixon Posted July 7, 2007 Author Share Posted July 7, 2007 Looks like you need to learn about Frames. Please see _IEFrameGetObjByNameDaleI have added this code:CODE$oFrames = _IEFrameGetCollection ($oIEL)$iNumFrames = @extendedIf $iNumFrames > 0 Then If _IEIsFrameSet ($oIEL) Then MsgBox(0, "Frame Info", "Page contains " & $iNumFrames & " frames in a FrameSet") Else MsgBox(0, "Frame Info", "Page contains " & $iNumFrames & " iFrames") EndIfElse MsgBox(0, "Frame Info", "Page contains no frames")EndIf$oElements = _IETagNameAllGetCollection ($oIEL)For $oElement In $oElements MsgBox(0, "Element Info", "Tagname: " & $oElement.tagname & @CR & "innerText: " & $oElement.innerText)Next_IEIsFrameset() tells me that there are two frames within a frame set (whatever that means)_IETagNameAllGetCollection() Gives me tagnames like HTML, Frame, Meta with inner values of "0" (Whatever that means) and:$oFrame = _IEFrameGetObjByName ($oIEL, "HTML")_IEBodyWriteHTML ($oFrame, "Hello <b>iFrame!</b>")_IELoadWait ($oFrame)This does nothing beause I am not sure if "HTML" is the objects name?Ant.. Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 7, 2007 Share Posted July 7, 2007 What page are you working with now? Is it the logon pop-up window? How did you attach to it? Did you use _IEBodyReadHTML() on it see what the code looks like? Your code snippet doesn't help because it doesn't show what IE object you are working on. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
anixon Posted July 8, 2007 Author Share Posted July 8, 2007 What page are you working with now? Is it the logon pop-up window? How did you attach to it? Did you use _IEBodyReadHTML() on it see what the code looks like?Your code snippet doesn't help because it doesn't show what IE object you are working on. Thanks for the reply. Yes I am now trying to process against the logon pop-up window. The following code contains the complete routine including the reporting aspects your help would be very much appreciated.CODE#include <IE.au3>GLOBAL $oIEL = ""$oIE = _IECreate("www.anz.com.au")_IELoadWait($oIE)WinSetState("ANZ HomePage", "", @SW_MAXIMIZE)$oForm = _IEFormGetObjByName($oIE, "login_form")_IEImgClick($oForm, "log on", "alt")$oIEL = _IEAttach ("https://www.anz.com/inetbank/bankmain.asp", "url")If IsObj($oIEL) Then MsgBox(64, "Message", "I think I am attached")Else MsgBox(16, "Message", 'I am not attached')EndIf$sHTML = _IEBodyReadHTML ($oIEL)msgbox(0,"",$sHTML)ConsoleWrite(_IEBodyReadHTML($oIEL) & @CR)$oFrames = _IEFrameGetCollection ($oIEL)$iNumFrames = @extendedIf $iNumFrames > 0 Then If _IEIsFrameSet ($oIEL) Then MsgBox(0, "Frame Info", "Page contains " & $iNumFrames & " frames in a FrameSet") Else MsgBox(0, "Frame Info", "Page contains " & $iNumFrames & " iFrames") EndIfElse MsgBox(0, "Frame Info", "Page contains no frames")EndIf$oElements = _IETagNameAllGetCollection ($oIEL)For $oElement In $oElements MsgBox(0, "Element Info", "Tagname: " & $oElement.tagname & @CR & "innerText: " & $oElement.innerText)Next$oFrame = _IEFrameGetObjByName ($oIEL, "data")_IEBodyWriteHTML ($oFrame, "Hello <b>iFrame!</b>")_IELoadWait ($oFrame)ThanksAnt.. Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 8, 2007 Share Posted July 8, 2007 Well, this version gets the HTML from the two frames in the frame set on the log on pop-up: #include <IE.au3> Global $oIE = _IECreate("www.anz.com.au", 1) $oForm = _IEFormGetObjByName($oIE, "login_form") If Not WinExists("https://www.anz.com/inetbank/bankmain.asp") Then _IEImgClick($oForm, "log on", "alt") WinWait("https://www.anz.com/inetbank/bankmain.asp", "", 5) EndIf $oIEL = _IEAttach("https://www.anz.com/inetbank/bankmain.asp", "url") If IsObj($oIEL) Then $sHTML = _IEBodyReadHTML($oIEL) ConsoleWrite("Log on pop-up:" & @CR & $sHTML & @CR) $colFrames = _IEFrameGetCollection($oIEL) $iNumFrames = @extended If $iNumFrames > 0 Then If _IEIsFrameSet($oIEL) Then ConsoleWrite("Page contains " & $iNumFrames & " frames in a FrameSet" & @CR) Else ConsoleWrite("Page contains " & $iNumFrames & " iFrames" & @CR) EndIf For $i = 0 To ($iNumFrames - 1) $oFrame = _IEFrameGetCollection($oIEL, $i) $sHTML = _IEBodyReadHTML($oFrame) ConsoleWrite("Frame: " & $i & @CR & $sHTML & @CR) $i += 1 Next Else MsgBox(0, "Frame Info", "Page contains no frames") EndIf Else MsgBox(16, "Error", "Faile to attach to pop-up logon window.") EndIf Once again, I removed stuff I didn't understand, like not reusing windows that were already open, maximizing, and whatever that _IEBodyWriteHTML() was supposed to be for. But you get the HTML to look at now on the console. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
anixon Posted July 8, 2007 Author Share Posted July 8, 2007 Well, this version gets the HTML from the two frames in the frame set on the log on pop-up: #include <IE.au3> Global $oIE = _IECreate("www.anz.com.au", 1) $oForm = _IEFormGetObjByName($oIE, "login_form") If Not WinExists("https://www.anz.com/inetbank/bankmain.asp") Then _IEImgClick($oForm, "log on", "alt") WinWait("https://www.anz.com/inetbank/bankmain.asp", "", 5) EndIf $oIEL = _IEAttach("https://www.anz.com/inetbank/bankmain.asp", "url") If IsObj($oIEL) Then $sHTML = _IEBodyReadHTML($oIEL) ConsoleWrite("Log on pop-up:" & @CR & $sHTML & @CR) $colFrames = _IEFrameGetCollection($oIEL) $iNumFrames = @extended If $iNumFrames > 0 Then If _IEIsFrameSet($oIEL) Then ConsoleWrite("Page contains " & $iNumFrames & " frames in a FrameSet" & @CR) Else ConsoleWrite("Page contains " & $iNumFrames & " iFrames" & @CR) EndIf For $i = 0 To ($iNumFrames - 1) $oFrame = _IEFrameGetCollection($oIEL, $i) $sHTML = _IEBodyReadHTML($oFrame) ConsoleWrite("Frame: " & $i & @CR & $sHTML & @CR) $i += 1 Next Else MsgBox(0, "Frame Info", "Page contains no frames") EndIf Else MsgBox(16, "Error", "Faile to attach to pop-up logon window.") EndIf Once again, I removed stuff I didn't understand, like not reusing windows that were already open, maximizing, and whatever that _IEBodyWriteHTML() was supposed to be for. But you get the HTML to look at now on the console. Thank you for the code which produced what appears to be a very comprehenisve report for the Logon Popup. Unfortunately I do not have enough knowledge about Java and I guess other relevant issues to be able to convert that information into an AutoIT sequence that will pass the user name and password data to their respective fields on the logon popup. I guess that _IEBodyWriteHTML was an attempt to pass data to the username field on the webpage (probably akin to stumbling around in the dark). Processing against CBA and Westpac pale in significance when compared to trying to get what at first appeared to be a relatively simple procedure to work when a Popup is involved. Any help with achieving the final outcome would be appreciated. Ant.. Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 8, 2007 Share Posted July 8, 2007 This gets all the way to clicking the log on image in the login pop-up. I'm not going to test or work on it any further, as that would start pinging at their server with invalid logins, since I don't have an account. expandcollapse popup#include <IE.au3> Global $CorporateSignonCorID = "1234567890" Global $CorporateSignonPassword = "password" Global $oIE = _IECreate("www.anz.com.au", 1) $oForm = _IEFormGetObjByName($oIE, "login_form") If Not WinExists("https://www.anz.com/inetbank/bankmain.asp") Then _IEImgClick($oForm, "log on", "alt") If Not WinWait("https://www.anz.com/inetbank/bankmain.asp", "", 10) Then ConsoleWrite("Error: Logon pop-up did not open before timeout." & @LF) Exit EndIf EndIf $oIEL = _IEAttach("https://www.anz.com/inetbank/bankmain.asp", "url") _IELoadWait($oIEL) If IsObj($oIEL) Then ConsoleWrite("Successfully attached to login pop-up." & @CR) $oFrame = _IEFrameGetCollection($oIEL, 0) If IsObj($oFrame) Then ConsoleWrite("Successfully retrieved Frame 0 object." & @CR) $oForm = _IEFormGetObjByName($oFrame, "loginForm") If IsObj($oForm) Then ConsoleWrite("Successfully retrieved loginForm object." & @CR) $oCRN = _IEFormElementGetObjByName($oForm, "CorporateSignonCorpID") If IsObj($oCRN) Then ConsoleWrite("Successfully retrieved CorporateSignonCorpID object." & @CR) $oPass = _IEFormElementGetObjByName($oForm, "CorporateSignonPassword") If IsObj($oPass) Then ConsoleWrite("Successfully retrieved CorporateSignonPassword object." & @CR) _IEFormElementSetValue($oCRN, $CorporateSignonCorID) Sleep(500) _IEFormElementSetValue($oPass, $CorporateSignonPassword) Sleep(500) _IEImgClick($oForm, "log on", "alt") Else ConsoleWrite("Error: Failed to get CorporateSignonPassword object." & @CR) EndIf Else ConsoleWrite("Error: Failed to get CorporateSignonCorpID object." & @CR) EndIf Else ConsoleWrite("Error: Failed to get loginForm object.") EndIf Else ConsoleWrite("Error: Failed to get Frame 0 object.") EndIf Else MsgBox(16, "Error", "Faile to attach to pop-up logon window.") EndIf This has been a useful project for me, as I'm just learning the IE UDF commands. But I'm done with it now. Hope you git'er done with your own account. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
anixon Posted July 9, 2007 Author Share Posted July 9, 2007 This gets all the way to clicking the log on image in the login pop-up. I'm not going to test or work on it any further, as that would start pinging at their server with invalid logins, since I don't have an account. expandcollapse popup#include <IE.au3> Global $CorporateSignonCorID = "1234567890" Global $CorporateSignonPassword = "password" Global $oIE = _IECreate("www.anz.com.au", 1) $oForm = _IEFormGetObjByName($oIE, "login_form") If Not WinExists("https://www.anz.com/inetbank/bankmain.asp") Then _IEImgClick($oForm, "log on", "alt") If Not WinWait("https://www.anz.com/inetbank/bankmain.asp", "", 10) Then ConsoleWrite("Error: Logon pop-up did not open before timeout." & @LF) Exit EndIf EndIf $oIEL = _IEAttach("https://www.anz.com/inetbank/bankmain.asp", "url") _IELoadWait($oIEL) If IsObj($oIEL) Then ConsoleWrite("Successfully attached to login pop-up." & @CR) $oFrame = _IEFrameGetCollection($oIEL, 0) If IsObj($oFrame) Then ConsoleWrite("Successfully retrieved Frame 0 object." & @CR) $oForm = _IEFormGetObjByName($oFrame, "loginForm") If IsObj($oForm) Then ConsoleWrite("Successfully retrieved loginForm object." & @CR) $oCRN = _IEFormElementGetObjByName($oForm, "CorporateSignonCorpID") If IsObj($oCRN) Then ConsoleWrite("Successfully retrieved CorporateSignonCorpID object." & @CR) $oPass = _IEFormElementGetObjByName($oForm, "CorporateSignonPassword") If IsObj($oPass) Then ConsoleWrite("Successfully retrieved CorporateSignonPassword object." & @CR) _IEFormElementSetValue($oCRN, $CorporateSignonCorID) Sleep(500) _IEFormElementSetValue($oPass, $CorporateSignonPassword) Sleep(500) _IEImgClick($oForm, "log on", "alt") Else ConsoleWrite("Error: Failed to get CorporateSignonPassword object." & @CR) EndIf Else ConsoleWrite("Error: Failed to get CorporateSignonCorpID object." & @CR) EndIf Else ConsoleWrite("Error: Failed to get loginForm object.") EndIf Else ConsoleWrite("Error: Failed to get Frame 0 object.") EndIf Else MsgBox(16, "Error", "Faile to attach to pop-up logon window.") EndIf This has been a useful project for me, as I'm just learning the IE UDF commands. But I'm done with it now. Hope you git'er done with your own account. Thank you for your help I will test your code later today. In the meantime I have been working on sites where the input is based on a form. You will note that I have changed the methodology for opening a https web page and have been able to get the code to work on a number of credit union internet banking sites. I am actually working on 24 sites of interest If I am successful I will give you a copy of the code for comment. This is for FORMS I have included some reporting which can be deleted out after you are satisfied that it works on the site of interest Ant.. CODE#include <IE.au3> $site = 2 ;Open Blank Page $oIE = _IECreate() ;Navigate to selected site if $site = 1 then _IENavigate($oIE, "https://netteller2.tsw.com.au/803205/ntv4.asp?wci=entry") $element1 = "mno" $element2 = "pwd" elseIf $site = 2 then _IENavigate($oIE, "https://online.mecu.com.au/daib/logon/cu3140/logon.asp") $element1 = "mn" $element2 = "pwd" EndIf ;Get name of form and set variable $oForms = _IEFormGetCollection ($oIE) MsgBox(0, "Forms Info", "There are " & @extended & " forms on this page") For $oForm In $oForms MsgBox(0, "Form Info", $oForm.name) Next ;Get name of input elements $oQuerys = _IEFormElementGetCollection ($oForm, -1) MsgBox(0, "Forms Info", "There are " & @extended & " elements on this page") For $oQuery In $oQuerys msgbox(0,"",$oQuery.name,1) Next ;Check for frames $oFrames = _IEFrameGetCollection ($oIE) $iNumFrames = @extended For $i = 0 to ($iNumFrames - 1) $oFrame = _IEFrameGetCollection ($oIE, $i) MsgBox(0, "Frame Info", _IEPropertyGet ($oFrame, "locationurl")) Next ;Process data to input fields $oForm = _IEFormGetObjByName($oIE, $oForm.name) $oQuery = _IEFormElementGetObjByName($oForm, $element1) _IEFormElementSetValue($oQuery, "Test") $oQuery = _IEFormElementGetObjByName($oForm, $element2) _IEFormElementSetValue($oQuery, "Test") Thanks again for your help which clearly has involved a lot of time and effort Cheers Ant... Link to comment Share on other sites More sharing options...
anixon Posted July 9, 2007 Author Share Posted July 9, 2007 This General Help and Support Forum covering IE.au3 should provide interested users with IMPORTANT INFORMATION in relation to processing Forms and Frames.On this subject an extra special mention must go not only to 'DaleHohm' but also 'PsaltyDS' who stuck with the issue until a solution was found.What can I say but thanks I really appreciated your help and especially the time you have given to teach me/us the awesome ways of AutoIT.Ant.. 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