IamKJ Posted March 26, 2017 Share Posted March 26, 2017 Have been having some serious issues with clicking a website button. I have eventually tried to even call for pixel of the button and then click, but still not working. I would ideally like to get the element of the button and click it that way above all else, but can't find out how/don't know. The element doesn't have an ID and trying to get by class or tag is not working. This is the element in question <div class="button small"><a class="btn-login" href="#">Login</a></div> Any help would be amazing. Below is my current script expandcollapse popup$ie = ObjCreate("InternetExplorer.Application") AutoItSetOption ("MouseCoordMode", 0) Opt('SendKeyDelay', Random (16,80)); default 5. higher number = slower #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <ComboConstants.au3> #include <WinHttp.au3> #include <IE.au3> #include <GUIConstantsEx.au3> #include <GuiEdit.au3> #include <WinAPIFiles.au3> #Region ### START Koda GUI section ### Form=c:\users\jammmesss\desktop\autoit\login.kxf Global $nameInfo = IniRead('Userinfo.ini', 'Name', 'Name', 'No username on file') Global $passInfo = IniRead('Userinfo.ini', 'Pass', 'Pass', 'No password on file') Global $Login = GUICreate("Login", 244, 162, 483, 309) GUISetBkColor(0xA0A0A0) Global $Username = GUICtrlCreateInput($nameInfo, 8, 32, 105, 21) GUICtrlSetBkColor(-1, 0xFFFFFF) Global $Password = GUICtrlCreateInput($passInfo, 128, 32, 105, 21) GUICtrlSetBkColor(-1, 0xFFFFFF) Global $logBtn = GUICtrlCreateButton("Login", 16, 120, 75, 33) GUICtrlSetBkColor(-1, 0xFFFFFF) Global $UserT = GUICtrlCreateLabel("User name", 24, 8, 55, 17) Global $PassT = GUICtrlCreateLabel("Password", 152, 8, 50, 17) Global $saveBtn = GUICtrlCreateButton("Save Info", 152, 120, 75, 33) GUICtrlSetBkColor(-1, 0xFFFFFF) Global $WorldT = GUICtrlCreateLabel("World", 104, 56, 32, 17) Global $WorldMen = GUICtrlCreateCombo("92", 88, 80, 65, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) ; Add additional items to the combobox. GUICtrlSetData($WorldMen, "91|90|89|88") GUICtrlSetBkColor(-1, 0xFFFFFF) GUISetState(@SW_SHOW) Global $slpMed = Random (2000, 2500) Global $slpLow = Random (100, 350) Global $pWorld = GUICtrlRead ($WorldMen) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $saveBtn $User = GUICtrlRead($Username) IniWrite("Userinfo.ini", "Name", "Name", $User) $Pass = GUICtrlRead ($Password) IniWrite("Userinfo.ini", "Pass", "Pass", $Pass) Case $logBtn $User = GUICtrlRead($Username) $Pass = GUICtrlRead ($Password) With $ie .visible = True WinActivate ($ie) .navigate ("*********t") While ($ie.busy) WEnd Sleep ($slpLow) $txtUser = .document.getElementById('user') $txtUser.value = $User Sleep ($slpLow) $txtPass = .document.getElementById('password') $txtPass.value = $Pass Sleep ($slpMed) Call (SearchForColor) EndWith EndSwitch WEnd Func SearchForColor () $left = 724 $top = 421 $right = 767 $bottom = 432 $color = 0x9C006F $pixLog = PixelSearch($left, $top, $right, $bottom, $color, 20) If not (@error) Then MouseClick('left',$pixLog[0],$pixLog[1],2,1) Else MsgBox(0,"Error","There has been an error with $pixLog") EndIf EndFunc Link to comment Share on other sites More sharing options...
Subz Posted March 26, 2017 Share Posted March 26, 2017 Have you tried using the IE UDF for example _IEAction($oIE, "Click") or _IEFormSubmit? Link to comment Share on other sites More sharing options...
IamKJ Posted March 26, 2017 Author Share Posted March 26, 2017 I haven't. How would I identify this button as an object?? Link to comment Share on other sites More sharing options...
Subz Posted March 26, 2017 Share Posted March 26, 2017 Are you able to post the html for the <form></form> ? Link to comment Share on other sites More sharing options...
IamKJ Posted March 26, 2017 Author Share Posted March 26, 2017 Wouldn't that still require getting the objects name? Link to comment Share on other sites More sharing options...
Subz Posted March 26, 2017 Share Posted March 26, 2017 If you have the form id you can then submit the form using the _IEFormSubmit, if you had a classname or button name you can use _IEAction Link to comment Share on other sites More sharing options...
IamKJ Posted March 26, 2017 Author Share Posted March 26, 2017 Thanks for the tip. Just attempted to call this function, with no luck. Any ideas? Func logBtn () Local $oInputs = _IETagNameGetCollection($ie, "div") For $oInput In $oInputs If $oInput.classname == "btn-login" Then _IEAction($oInput, "click") Next EndFunc Link to comment Share on other sites More sharing options...
Subz Posted March 26, 2017 Share Posted March 26, 2017 _IETagNameGetCollection($ie, "input") maybe Link to comment Share on other sites More sharing options...
IamKJ Posted March 26, 2017 Author Share Posted March 26, 2017 All that is happening is that it's activating the window, but not actually clicking anything. Link to comment Share on other sites More sharing options...
Subz Posted March 26, 2017 Share Posted March 26, 2017 As I mentioned can you post the form information otherwise really just guessing? Link to comment Share on other sites More sharing options...
IamKJ Posted March 26, 2017 Author Share Posted March 26, 2017 fghdg <form id="login_form" action="#" method="post"> <input type="submit" class="submit" id="login_submit_button"> <label for="user"> <input id="user" name="username" type="text" value=""> <span>User name:</span> </label> <label for="password"> <input name="clear" type="hidden" value="true"> <input id="password" name="password" type="password"> <span>Password:</span> </label> <label for="remember-me" class="remember_me"> <span class="remember-me">Remember me</span> <input id="remember-me" type="checkbox" name="remember-me" > </label> <div class="login-buttons"> <a class="login-facebook" href="https://ipp-facebook.******.de/?game=*****e&******t=en&ref=start&"></a> <div class="button small"><a class="btn-login" href="#">Login</a></div> </div> </form> Link to comment Share on other sites More sharing options...
IamKJ Posted March 26, 2017 Author Share Posted March 26, 2017 Ahh, sent that premature, lmao. Link to comment Share on other sites More sharing options...
Developers Jos Posted March 26, 2017 Developers Share Posted March 26, 2017 (edited) 3 minutes ago, IamKJ said: /?game= Seems you have missed our forum rules which explicitly prohibit game automation discussions. Please take the opportunity now to read them. Jos Edited March 26, 2017 by Jos 232showtime 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Recommended Posts