druiddk Posted May 17, 2006 Share Posted May 17, 2006 (edited) I tried using {TAB} to get to the frame with the form but it does not seem to work... If I navigate directly to the page with the form on the script works perfectly, however the submit button does not work when opened directly. There must be some way to define what frame i want it to look at!!! Any tips or suggestions would be deeply appreciated! Heres the code: #include <IE.au3> $o_IE = _IECreate () _IENavigate ($o_IE, "http://interflora.nonstop.dk") $o_SearchForm = _IEFormGetObjByName ($o_IE, "LoginForm") $o_Username = _IEFormElementGetObjByName ($o_SearchForm, "username") $o_Password = _IEFormElementGetObjByName ($o_SearchForm, "password") _IEFormElementSetValue ($o_Username, "testuser") _IEFormElementSetValue ($o_Password, "testpass") _IEFormSubmit ($o_SearchForm) (I'm using the beta version) Edited May 17, 2006 by druiddk Link to comment Share on other sites More sharing options...
DaleHohm Posted May 17, 2006 Share Posted May 17, 2006 You must get a reference to the particular frame first... $o_IE = _IECreate ( "http://interflora.nonstop.dk") $oFrame = _IEFrameGetObjByName($o_IE, "WinMain") Then use $oFrame instead of $o_IE in the remaining code... make sense? 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...
druiddk Posted May 17, 2006 Author Share Posted May 17, 2006 Yiihhaaaww! That makes perfect sence! Thank you so much Link to comment Share on other sites More sharing options...
druiddk Posted May 17, 2006 Author Share Posted May 17, 2006 (edited) Dunno if I should start a new topic with this problem but I will try post here again Alright so I got the form functions to work thanks toDaleHohn I would then like to go trough the source and find 3 constant spanids and then insert the value of the spanids into 3 variables (one variable for each spanid just to be clear!). Maybe the _IEBodyReadHTML function would be the way to go unless there is a better way? BTW: Is it possible to use _IEClickLinkByText with a partial text of a link (if im sure its always a unique number which is part of a link)...? Edited May 17, 2006 by druiddk Link to comment Share on other sites More sharing options...
Vinícius Morais Posted May 17, 2006 Share Posted May 17, 2006 What to make if form it does not have name? Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted May 17, 2006 Moderators Share Posted May 17, 2006 (edited) Dunno if I should start a new topic with this problem but I will try post here again Alright so I got the form functions to work thanks toDaleHohn I would then like to go trough the source and find 3 constant spanids and then insert the value of the spanids into 3 variables (one variable for each spanid just to be clear!).This should get what you want: $aIds = _ArrayCreate(0) ; get a collection object for all span tags $oSpans = _IETagNameGetCollection ($oIE, "SPAN") ; get the id value for each span tag For $oSpan In $oSpans $sId = $oSpan.id If Not $sId = "" Then _ArrayAdd($aIds, $sId) EndIf Next ; set the first element (0) to equal the number of ids found $aIds[0] = UBound($aIds) - 1 ; display the array _ArrayDisplay($aIds, "Your ID's") BTW: Is it possible to use _IEClickLinkByText with a partial text of a link (if im sure its always a unique number which is part of a link)...?Yes Edit: removed syntax highlighting Edited May 17, 2006 by big_daddy Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted May 17, 2006 Moderators Share Posted May 17, 2006 What to make if form it does not have name?You can use _IEFormGetCollection ( $o_object , $i_index ), where $i_index is the 0 based index of the form. Link to comment Share on other sites More sharing options...
druiddk Posted May 18, 2006 Author Share Posted May 18, 2006 @big_daddy: Thanks! Im trying to understand your code (sorry, but im very new to AutoIT). I would need to get like $fleur set from the spanid="fleur" Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted May 18, 2006 Moderators Share Posted May 18, 2006 (edited) @big_daddy: Thanks! Im trying to understand your code (sorry, but im very new to AutoIT). I would need to get like $fleur set from the spanid="fleur"I'm not real sure where your getting the "spanid" from, as far as I know it is <span id="something" If that is what you are refering to then you could use something like this: $aIds = _ArrayCreate(0) ; get a collection object for all span tags $oSpans = _IETagNameGetCollection ($oIE, "SPAN") ; get the id value for each span tag For $oSpan In $oSpans $sId = $oSpan.id If Not $sId = "" Then _ArrayAdd($aIds, $sId) EndIf Next ; set the first element (0) to equal the number of ids found $aIds[0] = UBound($aIds) - 1 ; display the array _ArrayDisplay($aIds, "Your ID's") ; assign each span id to a variable For $i = 1 To UBound($aIds) - 1 If Not IsDeclared($aIds[$i]) Then Assign($aIds[$i], $i) EndIf Next ; use eval to avoid warning messages MsgBox(0, "", Eval("fleur")) Edited May 19, 2006 by big_daddy Link to comment Share on other sites More sharing options...
druiddk Posted May 22, 2006 Author Share Posted May 22, 2006 (edited) Thank you for taking time to help me I'm getting an error on line 18: $aIds = _ArrayCreate(0) Error: Unknown function name. #include <IE.au3> $o_IE = _IECreate ( "http://interflora.nonstop.dk") $oFrame = _IEFrameGetObjByName($o_IE, "winMain") $o_SearchForm = _IEFormGetObjByName ($oFrame, "LoginForm") $o_Username = _IEFormElementGetObjByName ($o_SearchForm, "username") $o_Password = _IEFormElementGetObjByName ($o_SearchForm, "password") _IEFormElementSetValue ($o_Username, "testuser") _IEFormElementSetValue ($o_Password, "testpass") _IEFormSubmit ($o_SearchForm) _IELoadWait ($o_IE) _IEClickLinkByText ($oFrame, "Buketten (3210)") _IELoadWait ($o_IE) $aIds = _ArrayCreate(0) ; get a collection object for all span tags $oSpans = _IETagNameGetCollection ($oIE, "SPAN") ; get the id value for each span tag For $oSpan In $oSpans $sId = $oSpan.id If Not $sId = "" Then _ArrayAdd($aIds, $sId) EndIf Next ; set the first element (0) to equal the number of ids found $aIds[0] = UBound($aIds) - 1 ; display the array _ArrayDisplay($aIds, "Your ID's") Edited May 22, 2006 by druiddk Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted May 22, 2006 Moderators Share Posted May 22, 2006 Thank you for taking time to help me I'm getting an error on line 18: $aIds = _ArrayCreate(0) Error: Unknown function name. Sorry, add this to the top of your script: #include <Array.au3> Link to comment Share on other sites More sharing options...
druiddk Posted May 22, 2006 Author Share Posted May 22, 2006 (edited) Big_daddy - I cannot tell u how much I appreciate you taking time to help me here. Just incase someone else decises to look at this they will also need to change $oSpans = _IETagNameGetCollection ($oIE, "SPAN") into $oSpans = _IETagNameGetCollection ($o_IE, "SPAN") However currently it only returns [0] = 0 EDIT: AHA! Actually it should obviously be $oSpans = _IETagNameGetCollection ($oFrame, "SPAN") Otherwise it wont look at the right frame... Edited May 22, 2006 by druiddk Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted May 22, 2006 Moderators Share Posted May 22, 2006 Big_daddy - I cannot tell u how much I appreciate you taking time to help me here.No problem, glad I could help. Just incase someone else decises to look at this they will also need to change $oSpans = _IETagNameGetCollection ($oIE, "SPAN") into $oSpans = _IETagNameGetCollection ($o_IE, "SPAN")Variables with an underscore are used for UDFs, I would suggest that you remove the underscores from your script. However currently it only returns [0] = 0If it is returning "0", then it didn't find any specified id values. Link to comment Share on other sites More sharing options...
druiddk Posted May 22, 2006 Author Share Posted May 22, 2006 (edited) Problem with the missing ids were it did not look at the frame Seems last problem remaining is how to fetch a id from the array into a variable then. I tried like this:MsgBox(0, "Test", $alds[50]) but it fails with variable used without first being declared... Hmm!! Im not sure I know what the problem is but this works (nearly):MsgBox(0, "Test", $aIds[50]) However it only returns the name of id50... i wanted it to return the value of id 50... Edited May 22, 2006 by druiddk Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted May 22, 2006 Moderators Share Posted May 22, 2006 Problem with the missing ids were it did not look at the frame Seems last problem remaining is how to fetch a id from the array into a variable then. I tried like this:MsgBox(0, "Test", $alds[50]) but it fails with variable used without first being declared... Hmm!! Im not sure I know what the problem is but this works (nearly):MsgBox(0, "Test", $aIds[50]) However it only returns the name of id50... i wanted it to return the value of id 50...I gave an example here of how to assign a variable using the value of each id. If thats not what you are looking to do, please explain with more detail as to what you are wanting. Link to comment Share on other sites More sharing options...
Bert Posted May 22, 2006 Share Posted May 22, 2006 @Valuter: I wonder if you could add this to AuotIt 1 2 3? Make it easier to learn. I'm just starting to use it, and getting a lottle lost in all the commands. I should have it down soon, but a lesson like the one you made would rock! Just putting a bug in your ear to think about..... The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
druiddk Posted May 23, 2006 Author Share Posted May 23, 2006 Alright I got this running now as I wanted it to $aIds = _ArrayCreate(0) ; get a collection object for all span tags $oSpans = _IETagNameGetCollection ($oFrame, "SPAN") ; get the id value for each span tag For $oSpan In $oSpans $sId = $oSpan.innerHTML If Not $sId = "" Then _ArrayAdd($aIds, $sId) EndIf Next ; set the first element (0) to equal the number of ids found $aIds[0] = UBound($aIds) - 1 $mail = $aIds[58] $efleur = $aIds[60] $ip = $aIds[62] MsgBox(0, "Test", $ip) @volleyman - I dont believe Valuter is active in this thread? @big_daddy - Again thank you for taking your time to deal with my mindless questions 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