Jump to content

Recommended Posts

Posted (edited)

I've been fooling around with autoit for the past 2-3 days trying to get the hang of it. I feel like i'm getting somewhere but of course as any other new person, I run into problems.

So heres the situation. The following lines of code run fine, they just do not provide an actual log in. For example if i actually made it show the browser, it wouldn't log an account in. It just loads the page when I type my info and press the login button.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>

Tester()

Func Tester()
Local $msg
$tester= GUICreate("Login Tool", 300, 130, 10, 10)
GUICtrlCreateLabel("Username:", 27, 25)
GUICtrlCreateLabel("Password:", 30, 50)
$usr= GUICtrlCreateInput("Username", 85, 21, 190, 0)
$pw= GUICtrlCreateInput("Password", 85, 46, 190, 0, 0x0020)
$login= GUICtrlCreateButton("Login", 85, 71, 0, 0)
;$epvp= GUICtrlCreateCheckbox("EPVPERS", 100, 100) ignore
;$mpgh= GUICtrlCreateCheckbox("MPGH", 190, 100) ignore
GUISetState(@SW_SHOW)
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit

;---- as you can see I am trying to log into a website ----

        Case $msg = $login 
            $oIE = _IECreate ("http://www.mpgh.net/", 0, 0);<---- The website 
            $o_form = _IEFormGetObjByName ($oIE, login.php?do=login")  
            $o_login = _IEFormElementGetObjByName ($o_form, "vb_login_username") 
            $o_password = _IEFormElementGetObjByName ($o_form, "vb_login_password") 
            $o_signin = _IEFormElementGetObjByName ($o_form, "s")
            _IEFormElementSetValue ($o_login, GUICtrlRead($usr), 0) 
            _IEFormElementSetValue ($o_password, GUICtrlRead($pw), 0) 
            _IEAction ($o_signin, "click")
            ;Tool() <- Ignore this
    EndSelect       
WEnd
EndFunc

Basically what i'm trying to accomplish with this Func is to login to a hidden browser. But mainly I'm just trying to login to the website itself. I do not necessarily expect to get coding tips although they would be VERY helpful. But mainly a point in the right direction towards what I am trying to accomplish.

Side Note: No I'm not trying to hack this website or anything, I am in the work of making a community tool for them.

Edited by JSVCa
Posted

hey!!

you have to be sure that your are getting the right form object.

so this line might be wrong :

$o_form = _IEFormGetObjByName ($oIE, login.php?do=login")

as I can see with FireBug (FireFox developer add-on) :

form as no name, you may want to explore the finding by index

after that, test each input field at a time.

the login/password DOM object name you provided seem correct.

good luck!!

hench

Posted

I arrive too late...

#include <IE.au3>

$oIE = _IECreate ( "http://www.mpgh.net/" )
$colForms = _IEFormGetCollection ( $oIE )
For $oForm In $colForms
    $colElements = _IETagNameAllGetCollection ( $oForm )
    For $oElement In $colElements
        If $oForm.id = 0 And $oElement.getAttribute ( "name", 2 ) = 'vb_login_username' Then
            _IEFormElementSetValue ( $oElement, 'user' )
        EndIf
        If $oForm.id = 0 And $oElement.getAttribute ( "name", 2 ) = 'vb_login_password' Then
            _IEFormElementSetValue ( $oElement, 'password' )
            _IEFormSubmit ( $oForm )
            ExitLoop 2
        EndIf
    Next
Next

AutoIt 3.3.18.0 X86 - SciTE 4.4.6.0WIN 11 24H2 X64 - Other Examples Scripts

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...