newb_powa' Posted November 29, 2007 Share Posted November 29, 2007 I'm trying to automate a click on a button, but the problem is that the button got no ID. <INPUT style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; BORDER-LEFT: 1px solid; COLOR: white; BORDER-BOTTOM: 1px solid; BACKGROUND-COLOR: #554433" onclick=sendLevelUp(); type=button value="[ Ok! ]"> This is the html code of the button. I've looked trought the help file but I can't find any function that will create a reference to an object by his value. If there is a way just tell it to me, and if there is not, how can I click this button ? Between, the button is'nt in a form for what i can see. Thanks for help. Link to comment Share on other sites More sharing options...
DaleHohm Posted November 29, 2007 Share Posted November 29, 2007 (edited) You need to use either _IETagnameGetCollection or _IEFormElementGetCollection using an index. See the helpfile for examples. You are correct - there is no function to get something directly by value. Dale p.s. to click on it use _IEAction click Edited November 29, 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...
newb_powa' Posted November 29, 2007 Author Share Posted November 29, 2007 You need to use either _IETagnameGetCollection or _IEFormElementGetCollection using an index. See the helpfile for examples. You are correct - there is no function to get something directly by value.Dalep.s. to click on it use _IEAction clickI knew about Action ==> click, but I did'nt for _IETagnameGetCollection or _IEFormElementGetCollection, I will look what I get from those two function, thanks Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 29, 2007 Share Posted November 29, 2007 (edited) I'm trying to automate a click on a button, but the problem is that the button got no ID. <INPUT style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; BORDER-LEFT: 1px solid; COLOR: white; BORDER-BOTTOM: 1px solid; BACKGROUND-COLOR: #554433" onclick=sendLevelUp(); type=button value="[ Ok! ]"> This is the html code of the button. I've looked trought the help file but I can't find any function that will create a reference to an object by his value. If there is a way just tell it to me, and if there is not, how can I click this button ? Between, the button is'nt in a form for what i can see. Thanks for help. Check the help file for the _IE* functions. Play with the examples. You first need to get the DOM object for the button, i.e. with _IETagNameGetCollection(), then use _IEAction() with "click". Edit: Slow typing... beat to it. Edited November 29, 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...
DaleHohm Posted November 29, 2007 Share Posted November 29, 2007 Note that you can in fact find an element by value. but you need to loop through a collection to do it... see the example for _IETagnameGetCollection and examine the value of $oInput.value to find a match. 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...
newb_powa' Posted November 29, 2007 Author Share Posted November 29, 2007 Note that you can in fact find an element by value. but you need to loop through a collection to do it... see the example for _IETagnameGetCollection and examine the value of $oInput.value to find a match. Dale It does the trick $oInputs = _IETagNameGetCollection ($oIE, "input") For $oInput In $oInputs If $oInput.value = "[ Ok! ]" Then _IEAction ($oInput, "click") EndIf Next I just put here the code I've used so if someone have the same question, there is the answer. Thanks for the tips Dale Link to comment Share on other sites More sharing options...
DaleHohm Posted November 29, 2007 Share Posted November 29, 2007 Very good. Suggest you add an ExitLoop however to prevent errors for input tags in the collection after you click: $oInputs = _IETagNameGetCollection ($oIE, "input") For $oInput In $oInputs If $oInput.value = "[ Ok! ]" Then _IEAction ($oInput, "click") ExitLoop EndIf 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...
DaleHohm Posted November 29, 2007 Share Posted November 29, 2007 Edit: Slow typing... beat to it.@PsaltyDS -- If I'd known you were there, I would have gladly let you handle it 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...
Oldschool Posted November 29, 2007 Share Posted November 29, 2007 (edited) What if you use the debug bar and know the DOM location? How could you write that? $oInputs = _IETagNameGetCollection ($oIE, "input") If $oInput.234 = "[ Ok! ]" Then _IEAction ($oInput, "click") ExitLoop EndIf Edited November 29, 2007 by Oldschool 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