E1M1 Posted July 2, 2010 Share Posted July 2, 2010 I can't find _IE* func to click button by class. Any ideas about this? Html <a class="signIn" href="#" onclick="Login(); return false;"></a> edited Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 2, 2010 Share Posted July 2, 2010 Get the collection of all links with _IELinkGetCollection() then walk through them with a For/In/Next loop to find the one you want: $oFound = "" $colLinks = _IELinkGetCollection($oIE) For $oLink In $colLinks If $oLink.className & "" = "signIn" Then $oFound = $oLink ExitLoop EndIf Next If IsObj($oFound) Then MsgBox(64, "Success", "Found it!") Else MsgBox(16, "Failed", "Not found.") EndIf 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...
Annonyreeder Posted May 10, 2013 Share Posted May 10, 2013 Hi i have a similar issue, i tried your code but it does not seem to work for me? always comes back "Failed, Not found" <button class="action af_commandButton" onclick="submitForm('ManageUsers',1,{source:'_id106:_id133'});return false;" type="button"> $oFound = "" $colLinks = _IELinkGetCollection($oIE) For $oLink In $colLinks If $oLink.className & "" = "action af_commandButton" Then $oFound = $oLink ExitLoop EndIf Next If IsObj($oFound) Then MsgBox(64, "Success", "Found it!") Else MsgBox(16, "Failed", "Not found.") EndIf Link to comment Share on other sites More sharing options...
mikell Posted May 10, 2013 Share Posted May 10, 2013 You check a button not a link so you must adapt the code Local $oBtns = _IETagNameGetCollection($oIE, "button") For $oBtn In $oBtns If String($oBtn.classname) = "action af_commandButton" Then ;... your action EndIf Next Link to comment Share on other sites More sharing options...
Annonyreeder Posted May 10, 2013 Share Posted May 10, 2013 (edited) Thanks for your help, it seems to be working it now comes back saying "Found" howveer i still can't click it, have i done this right? thanks. $oFound = "" Local $oBtns = _IETagNameGetCollection($oIE, "button") For $oBtn In $oBtns If String($oBtn.classname) = "action af_commandButton" Then $oFound = $oBtn EndIf Next If IsObj($oFound) Then _IEAction ($oFound, "click") MsgBox(16, "Success", "Password23 with a captial P (Roles have been set)") Else MsgBox(16, "Failed", "Not found.") EndIf endfunc Edited May 10, 2013 by Annonyreeder Link to comment Share on other sites More sharing options...
Shrapnel Posted May 10, 2013 Share Posted May 10, 2013 I'm not sure this will work or not, but try to get the ID of the $oFound item and save it as $obtn, and then click the $obtn: Local $oFound = "" Local $oBtns = _IETagNameGetCollection($oIE, "button") For $oBtn In $oBtns If String($oBtn.classname) = "action af_commandButton" Then $oFound = $oBtn EndIf Next If IsObj($oFound) Then Local $obtn = _IEFormElementGetObjByName($o_IE, $oFound.id) ; Get ID of the button _IEAction ($obtn, "click") MsgBox(16, "Success", "Password23 with a captial P (Roles have been set)") Else MsgBox(16, "Failed", "Not found.") EndIf Link to comment Share on other sites More sharing options...
mikell Posted May 10, 2013 Share Posted May 10, 2013 Annonyreeder, In this If IsObj($oFound) Then _IEAction ($oFound, "click") MsgBox(16, "Success", "Password23 with a captial P (Roles have been set)") Else MsgBox(16, "Failed", "Not found.") EndIf Do you still get the success msgbox ? R0G 1 Link to comment Share on other sites More sharing options...
Annonyreeder Posted May 13, 2013 Share Posted May 13, 2013 Hello, sorry for late reply had 2 days off work, Using "Adventureer's" code it still shows "Success" but doesnt actually click the button :S Link to comment Share on other sites More sharing options...
DaleHohm Posted May 13, 2013 Share Posted May 13, 2013 If you are getting Success, it is actually performing a click event on the element. If it is not producing the desired results, it may be that more than a simple click is required. When you click with the mouse, you actually generate events onmousedown, onmouseup, click. So, you can try this: $oFound.fireEvent("onmousedown") $oFound.fireEvent("onmouseup") _IEAction($oFound, "click") 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...
Annonyreeder Posted June 9, 2013 Share Posted June 9, 2013 Hey i just found this post from awhile ago, and im still having the same problem, however the reason im getting the issue is because there are several buttons all with the exact same class + type the only part thta differs is the "Onclick" <BUTTON class="action af_commandButton" onclick="submitForm('ManageUsers',1,{source:'_id106:_id133'});return false;" type=button>Assign</BUTTON> 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