IamKJ

Trying to click website button

13 posts in this topic

#1 ·  Posted

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

$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

 

Share this post


Link to post
Share on other sites



#2 ·  Posted

Have you tried using the IE UDF for example _IEAction($oIE, "Click") or _IEFormSubmit?

Share this post


Link to post
Share on other sites

#3 ·  Posted

I haven't.  How would I identify this button as an object??

 

 

Share this post


Link to post
Share on other sites

#4 ·  Posted

Are you able to post the html for the <form></form> ?

Share this post


Link to post
Share on other sites

#5 ·  Posted

Wouldn't that still require getting the objects name?

Share this post


Link to post
Share on other sites

#6 ·  Posted

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

Share this post


Link to post
Share on other sites

#8 ·  Posted

_IETagNameGetCollection($ie, "input") maybe

Share this post


Link to post
Share on other sites

#9 ·  Posted

All that is happening is that it's activating the window, but not actually clicking anything.

Share this post


Link to post
Share on other sites

#10 ·  Posted

As I mentioned can you post the form information otherwise really just guessing?

Share this post


Link to post
Share on other sites

#11 ·  Posted

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>

 

Share this post


Link to post
Share on other sites

#12 ·  Posted

Ahh, sent that premature, lmao.

Share this post


Link to post
Share on other sites

#13 ·  Posted (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 by Jos
1 person likes this

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.