Bert 1,430 Posted September 30, 2010 (edited) I have a form that has various text fields, pick list, and so forth. I'm using this script to test with:Func _readFA_page() $Read = GUICtrlRead($Input1) $oIE = _IECreate("http://www.tfaforms.com/"&$Read) $oForms = _IEFormGetCollection ($oIE) For $oform In $oforms ConsoleWrite($oform.name & @CRLF); $oeles = _IEFormElementGetCollection($oform) For $oele In $oeles ConsoleWrite( 'ID: ' & $oele.name & @CRLF _ & ' Tag Type: ' & $oele.tagName & @CRLF _ & ' Tag style: '& $oele.type & @CRLF _ & ' Tag lable: '& $oele.innerHTML & @CRLF _ & @CRLF) ;Tried innerHTML, but that didn't work. Next Next EndFuncThe problem I'm having is I need to get the displayed label. For example I have this control in a page as shown in the HTML code below. The section I highlighted in red is what I need to get for what I'm building. What DHTML object do I call to get it?: <div id="tfa_OnSiteContactNam-D" class="oneField"><label class="preField" for="tfa_OnSiteContactNam">On Site Contact Name</label> <input type="text" id="tfa_OnSiteContactNam" name="tfa_OnSiteContactNam" value="" size="40" class=""> <br><span class="errMsg" id="tfa_OnSiteContactNam-E"> </span></div> Edited September 30, 2010 by MPH The Vollatran project My blog: http://www.vollysinterestingshit.com/ Share this post Link to post Share on other sites
Bert 1,430 Posted September 30, 2010 (edited) I tried "label", and "id" but they didn't work. "Label" crashed the script, and "id" returned the same as "name" Here is the output when I tested it on this field and I tried "id": ID: tfa_OnSiteContactNam Tag Type: INPUT Tag style: text Tag label: tfa_OnSiteContactNam Edited September 30, 2010 by MPH The Vollatran project My blog: http://www.vollysinterestingshit.com/ Share this post Link to post Share on other sites
DaleHohm 65 Posted October 1, 2010 I would do this: $oDiv = _IEGetObjById($oIE, "tfa_OnSiteContactNam-D") $oLabel = _IETagnameGetCollection($oDiv, "label", 0) ConsoleWrite(_IEPropertyGet($oLabel, "innertext") & @CRLF) Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curlMSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object modelAutomate input type=file (Related)Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better?IE.au3 issues with Vista - WorkaroundsSciTe 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 Share this post Link to post Share on other sites
Bert 1,430 Posted October 1, 2010 Sweet! that will do the trick nicely! Thanks! The Vollatran project My blog: http://www.vollysinterestingshit.com/ Share this post Link to post Share on other sites
Bert 1,430 Posted October 5, 2010 (edited) I'm still having a bit of trouble with this. I have a test script I have made with 2 similar forms. The only difference between the two forms is one has a section around the items. <fieldset id="tfa_fieldset" class="wfSection"> <legend>fieldset</legend> For some reason the section will break the script. The problem I'm having is I plan to use my script on many different forms. Some may have a field group, others won't. Any idea how to fix it? #include <IE.au3> $oIE = _IECreate("http://www.tfaforms.com/179750") ;has section ;$oIE = _IECreate("http://www.tfaforms.com/179754") ;does not have section _IELoadWait ($oIE) _IEErrorNotify (False) $sHTML = _IEBodyReadHTML ($oIE) MsgBox(0, "", $sHTML) $oForms = _IEFormGetCollection ($oIE) For $oform In $oforms ConsoleWrite($oform.name & @CRLF); $oeles = _IEFormElementGetCollection($oform) For $oele In $oeles $sr = string($oele.id) $S1 = StringInStr($sHTML, $sr) ConsoleWrite($s1 &@crlf) $s2 = Stringmid($sHTML, $S1, 40) ConsoleWrite($s2 &@crlf) $s3 = StringInStr($s2, "wfSection") ConsoleWrite($s3 &@crlf) if $s3 = 0 then $sr = string($oele.name)&'-D' endif ; $oDiv = _IEGetObjById($oIE,$sr ) IF @error = 0 THEN $oLabel = _IETagnameGetCollection($oDiv, "label", 0) ConsoleWrite( 'ID: ' & $oele.name & @CRLF _ & ' Tag Type: ' & $oele.tagName & @CRLF _ & ' Tag Style: '& $oele.type & @CRLF _ & ' Tag Label: '& _IEPropertyGet($oLabel, "innertext")& @CRLF & @CRLF) EndIf Next Next Edited October 5, 2010 by MPH The Vollatran project My blog: http://www.vollysinterestingshit.com/ Share this post Link to post Share on other sites
Bert 1,430 Posted October 5, 2010 (edited) OK, I played with it a bit more this morning and added _IEErrorHandlerRegister. My script no longer crashes, but I'm not getting all the fields when I search for them. It is missing the checkbox fields. I'm not sure on how to look for them. Any ideas? expandcollapse popup#include <IE.au3> $oIE = _IEAttach ("Test form for autoit script") if @error = 7 then $oIE = _IECreate("http://www.tfaforms.com/179750") ;has section _IEErrorHandlerRegister ("MyErrFunc") _IELoadWait ($oIE) $sHTML = _IEBodyReadHTML ($oIE) ConsoleWrite( $sHTML&@CRLF&@CRLF&@CRLF) ;post the HTML to the console for review $oForms = _IEFormGetCollection ($oIE) For $oform In $oforms ConsoleWrite($oform.name & @CRLF); $oeles = _IEFormElementGetCollection($oform) For $oele In $oeles $sr = string($oele.name)&'-D' $oDiv = _IEGetObjById($oIE,$sr ) IF @error = 0 THEN $oLabel = _IETagnameGetCollection($oDiv, "label", 0) ConsoleWrite( 'ID: ' & $oele.name & @CRLF _ & ' Tag Type: ' & $oele.tagName & @CRLF _ & ' Tag Style: '& $oele.type & @CRLF _ & ' Tag Label: '& _IEPropertyGet($oLabel, "innertext")& @CRLF & @CRLF) EndIf Next Next Func MyErrFunc() ; Important: the error object variable MUST be named $oIEErrorHandler $ErrorScriptline = $oIEErrorHandler.scriptline $ErrorNumber = $oIEErrorHandler.number $ErrorNumberHex = Hex($oIEErrorHandler.number, 8) $ErrorDescription = StringStripWS($oIEErrorHandler.description, 2) $ErrorWinDescription = StringStripWS($oIEErrorHandler.WinDescription, 2) $ErrorSource = $oIEErrorHandler.Source $ErrorHelpFile = $oIEErrorHandler.HelpFile $ErrorHelpContext = $oIEErrorHandler.HelpContext $ErrorLastDllError = $oIEErrorHandler.LastDllError $ErrorOutput = "" $ErrorOutput &= "--> COM Error Encountered in " & @ScriptName & @CR $ErrorOutput &= "----> $ErrorScriptline = " & $ErrorScriptline & @CR $ErrorOutput &= "----> $ErrorNumberHex = " & $ErrorNumberHex & @CR $ErrorOutput &= "----> $ErrorNumber = " & $ErrorNumber & @CR $ErrorOutput &= "----> $ErrorWinDescription = " & $ErrorWinDescription & @CR $ErrorOutput &= "----> $ErrorDescription = " & $ErrorDescription & @CR $ErrorOutput &= "----> $ErrorSource = " & $ErrorSource & @CR $ErrorOutput &= "----> $ErrorHelpFile = " & $ErrorHelpFile & @CR $ErrorOutput &= "----> $ErrorHelpContext = " & $ErrorHelpContext & @CR $ErrorOutput &= "----> $ErrorLastDllError = " & $ErrorLastDllError ConsoleWrite("COM Error"&@crlf& $ErrorOutput) SetError(1) Return EndFunc ;==>MyErrFunc Edited October 5, 2010 by MPH The Vollatran project My blog: http://www.vollysinterestingshit.com/ Share this post Link to post Share on other sites