bob57 Posted August 15, 2007 Share Posted August 15, 2007 Hi, I've got a page I need to interact with that has input elements not within a form The text fields I can manipulate using an object identifier, but I can't see how to get _IEFormElementRadioSelect working without a form reference/handle. I also need to do some select lists that are outside of the form, but I've not looked at those yet. I've build myself a tiny test page to play with. <html> <body> <input id="text" type="text" size="40" onclick="alert('text')"/> <input id="vat1" type="radio" name="vat-payable" value="Don't know" onclick="alert('radio 1')" /> <input id="vat2" type="radio" name="vat-payable" value="Yes" onclick="alert('radio 2')" /> <input id="vat3" type="radio" name="vat-payable" value="No" onclick="alert('radio 3')" /> </body> </html> Any insight/hacks would be appreciated. Cheers, Bob Link to comment Share on other sites More sharing options...
Mast3rpyr0 Posted August 15, 2007 Share Posted August 15, 2007 my help file doesnt work but theres a function called _IEGetObjById() maybe that wil do it. My UDF's : _INetUpdateCheck() My Programs : GameLauncher vAlpha, InfoCrypt, WindowDesigner, ScreenCap, DailyRemindersPick3GeneratorBackupUtility! Other : Bored? Click Here! Link to comment Share on other sites More sharing options...
GMK Posted August 15, 2007 Share Posted August 15, 2007 #include <IE.au3> $oHTML = "<html>" & @CRLF $oHTML &= "<body>" & @CRLF $oHTML &= "<input id=""text"" type=""text"" size=""40"" onclick=""alert('text')""/>" & @CRLF $oHTML &= "<input id=""vat1"" type=""radio"" name=""vat-payable"" value=""Don't know"" onclick=""alert('radio 1')"" />" & @CRLF $oHTML &= "<input id=""vat2"" type=""radio"" name=""vat-payable"" value=""Yes"" onclick=""alert('radio 2')"" />" & @CRLF $oHTML &= "<input id=""vat3"" type=""radio"" name=""vat-payable"" value=""No"" onclick=""alert('radio 3')"" />" & @CRLF $oHTML &= "</body>" & @CRLF $oHTML &= "</html>" $oIE = _IECreate() _IEDocWriteHTML($oIE, $oHTML) $oInput1 = _IEGetObjById($oIE, "text") $oInput2 = _IEGetObjById($oIE, "vat1") $oInput3 = _IEGetObjById($oIE, "vat2") $oInput4 = _IEGetObjById($oIE, "vat3") _IEFormElementSetValue($oInput1, "text") Sleep(1000) _IEAction($oInput2, "click") Sleep(1000) _IEAction($oInput3, "click") Sleep(1000) _IEAction($oInput4, "click") Sleep(1000) _IEQuit($oIE) Link to comment Share on other sites More sharing options...
bob57 Posted August 16, 2007 Author Share Posted August 16, 2007 Hi, Thanks, that did the job. Cheers, Bob Link to comment Share on other sites More sharing options...
DaleHohm Posted August 16, 2007 Share Posted August 16, 2007 If you are lucky enough to have ID's on all of those elements, them that is a very good solution. Note that _IEFormElementSetValue will do what you want for an INPUT TYPE=TEXT element, but for other elements you will most likely want to use _IEAction($oElement, "click") -- this is because you do not want to change the VALUE of those elements, but rather make certain the you select the one(s) with the value that you want. SELECT OPTION (drop-down, select and multi-select controls) are more complicated. The SELECT element in turn has a .OPTION collection under it. The SELECT has a NAME and the OPTIONs have both .text and .value properties. This all makes these things very confusing. Noteas as well that SELECT OPTION, RADIO and CHECKBOX elements all have a .checked property (TRUE or FALSE) that reveal or control whether they are selected or not. I have not worked out a generalized way to do all of this in IE.au3 when the elements are not in a form, but unfortunately, it is becomming more common practice. You may also find this approach useful: $oInputs = _IETagNameGetCollection($oIE, "input") For $oInput in $oInputs ; do some tests ; take some action 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 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