Sign in to follow this  
Followers 0
Floppy

What's wrong with this script

7 posts in this topic

Hello, I'm trying to do a bot which register automatically a new user on Live for Speed website.

The link to register is: https://www.lfs.net/?page=register

My script (not yet finished) is:

#include <GuiConstants.au3>
#include <IE.au3>

$gui=GUICreate('LFS Account Creator 0.1 (Alpha)',350,180)
GUICtrlCreateLabel('Username:',10,10,330,20)
$un_ipt=GUICtrlCreateInput('',10,25,330,20)
GUICtrlCreateLabel('Password:',10,60,330,20)
$psw_ipt=GUICtrlCreateInput('',10,75,330,20)
$ok=GUICtrlCreateButton('OK',10,120,330,40)
GUISetState(@SW_SHOW,$gui)

While 1
    $m=GUIGetMsg()
    Select
    Case $m=$GUI_EVENT_CLOSE
        Exit
    Case $m=$ok
        $un=GUICtrlRead($un_ipt)
        $psw=GUICtrlRead($psw_ipt)
        
        $ie=_IECreate('https://www.lfs.net/?page=register')
        
        $un_web=_IEGetObjByName($ie,'username')
        $mail_web=_IEGetObjByName($ie,'email')
        $country_web=_IEGetObjByName($ie,'country')
        $hear_web=_IEGetObjByName($ie,'reference')
        $psw_web=_IEGetObjByName($ie,'pass')
        $psw2_web=_IEGetObjByName($ie,'passcheck')
        
        _IEFormElementSetValue($un_web,$un)
        _IEFormElementSetValue($psw_web,$psw)
        _IEFormElementSetValue($psw2_web,$psw)
        
        
    EndSelect
WEnd

The problem is that I can't set the Username, but I don't know WHY?

The password is set, the Username NO!!!

I tried change variables names, but nothing...

Please, help me!

Share this post


Link to post
Share on other sites



Get form first

Then, get elements of form

Especially the function _IEFormElementGetObjByName

See Help for this function

; *******************************************************

; Example 1 - Get a reference to a specific form by name. In this case, submit a query

; to the Google search engine. Note that the names of the form and form

; elements can be found by viewing the page HTML source

; *******************************************************

;

#include <IE.au3>

$oIE = _IECreate ("http://www.google.com")

$oForm = _IEFormGetObjByName ($oIE, "f")

$oQuery = _IEFormElementGetObjByName ($oForm, "q")

_IEFormElementSetValue ($oQuery, "AutoIt IE.au3")

_IEFormSubmit ($oForm)

Is FSoft = FPT Soft (.vn)?

Hello, I'm trying to do a bot which register automatically a new user on Live for Speed website.

The link to register is: https://www.lfs.net/?page=register

My script (not yet finished) is:

#include <GuiConstants.au3>
#include <IE.au3>

$gui=GUICreate('LFS Account Creator 0.1 (Alpha)',350,180)
GUICtrlCreateLabel('Username:',10,10,330,20)
$un_ipt=GUICtrlCreateInput('',10,25,330,20)
GUICtrlCreateLabel('Password:',10,60,330,20)
$psw_ipt=GUICtrlCreateInput('',10,75,330,20)
$ok=GUICtrlCreateButton('OK',10,120,330,40)
GUISetState(@SW_SHOW,$gui)

While 1
    $m=GUIGetMsg()
    Select
    Case $m=$GUI_EVENT_CLOSE
        Exit
    Case $m=$ok
        $un=GUICtrlRead($un_ipt)
        $psw=GUICtrlRead($psw_ipt)
        
        $ie=_IECreate('https://www.lfs.net/?page=register')
        
        $un_web=_IEGetObjByName($ie,'username')
        $mail_web=_IEGetObjByName($ie,'email')
        $country_web=_IEGetObjByName($ie,'country')
        $hear_web=_IEGetObjByName($ie,'reference')
        $psw_web=_IEGetObjByName($ie,'pass')
        $psw2_web=_IEGetObjByName($ie,'passcheck')
        
        _IEFormElementSetValue($un_web,$un)
        _IEFormElementSetValue($psw_web,$psw)
        _IEFormElementSetValue($psw2_web,$psw)
        
        
    EndSelect
WEnd

The problem is that I can't set the Username, but I don't know WHY?

The password is set, the Username NO!!!

I tried change variables names, but nothing...

Please, help me!

Share this post


Link to post
Share on other sites

Thanks for reply!

Get form first

Then, get elements of form

Especially the function _IEFormElementGetObjByName

See Help for this function

; *******************************************************

; Example 1 - Get a reference to a specific form by name. In this case, submit a query

; to the Google search engine. Note that the names of the form and form

; elements can be found by viewing the page HTML source

; *******************************************************

;

#include <IE.au3>

$oIE = _IECreate ("http://www.google.com")

$oForm = _IEFormGetObjByName ($oIE, "f")

$oQuery = _IEFormElementGetObjByName ($oForm, "q")

_IEFormElementSetValue ($oQuery, "AutoIt IE.au3")

_IEFormSubmit ($oForm)

Yes, but where can I get elements? I tried this

$un=GUICtrlRead($un_ipt)
        $psw=GUICtrlRead($psw_ipt)
        
        $ie=_IECreate('https://www.lfs.net/?page=register')
        
        $un_web=_IEGetObjByName($ie,'v1id')
        $un_el_web=_IEFormElementGetObjByName($un_web,'username')
        $mail_web=_IEGetObjByName($ie,'email')
        $country_web=_IEGetObjByName($ie,'country')
        $hear_web=_IEGetObjByName($ie,'reference')
        $psw_web=_IEGetObjByName($ie,'pass')
        $psw2_web=_IEGetObjByName($ie,'passcheck')
        
        _IEFormElementSetValue($un_el_web,$un)
        _IEFormElementSetValue($psw_web,$psw)
        _IEFormElementSetValue($psw2_web,$psw)

but it doesn't work!

The strange thing is that I can set, for example, password and email...but I cannot set username! :)

P.S.: Is FSoft = FPT Soft (.vn)? No... :party:

Share this post


Link to post
Share on other sites

Any solution?

Share this post


Link to post
Share on other sites

Looks like you've attached the wrong form, since it looks like there's 3 on that page. Try your script then look at the top right username field...

Share this post


Link to post
Share on other sites

There are two "username" objects on that page, it _IEGetObjByName was looking at the wrong one. So we specify which form we want it to look at instead. It's working for me now... just removed/changed one line then added another. I made comments accordingly.

#include <GuiConstants.au3>
#include <IE.au3>

$gui=GUICreate('LFS Account Creator 0.1 (Alpha)',350,180)
GUICtrlCreateLabel('Username:',10,10,330,20)
$un_ipt=GUICtrlCreateInput('',10,25,330,20)
GUICtrlCreateLabel('Password:',10,60,330,20)
$psw_ipt=GUICtrlCreateInput('',10,75,330,20)
$ok=GUICtrlCreateButton('OK',10,120,330,40)
GUISetState(@SW_SHOW,$gui)

While 1
    $m=GUIGetMsg()
    Select
    Case $m=$GUI_EVENT_CLOSE
        Exit
    Case $m=$ok
        $un=GUICtrlRead($un_ipt)
        $psw=GUICtrlRead($psw_ipt)
       
        $ie=_IECreate('https://www.lfs.net/?page=register')
        
        $oForms = _IEFormGetCollection($ie, 2)      ;Added
               
        ;$un_web=_IEGetObjByName($ie,'username')    ;Removed
        $un_web=_IEFormElementGetObjByName($oForms,'username')  ;Added
        $mail_web=_IEGetObjByName($ie,'email')
        $country_web=_IEGetObjByName($ie,'country')
        $hear_web=_IEGetObjByName($ie,'reference')
        $psw_web=_IEGetObjByName($ie,'pass')
        $psw2_web=_IEGetObjByName($ie,'passcheck')
       
        _IEFormElementSetValue($un_web,$un)
        _IEFormElementSetValue($psw_web,$psw)
        _IEFormElementSetValue($psw2_web,$psw)
    EndSelect
WEnd

Share this post


Link to post
Share on other sites

There are two "username" objects on that page, it _IEGetObjByName was looking at the wrong one. So we specify which form we want it to look at instead. It's working for me now... just removed/changed one line then added another. I made comments accordingly.

#include <GuiConstants.au3>
#include <IE.au3>

$gui=GUICreate('LFS Account Creator 0.1 (Alpha)',350,180)
GUICtrlCreateLabel('Username:',10,10,330,20)
$un_ipt=GUICtrlCreateInput('',10,25,330,20)
GUICtrlCreateLabel('Password:',10,60,330,20)
$psw_ipt=GUICtrlCreateInput('',10,75,330,20)
$ok=GUICtrlCreateButton('OK',10,120,330,40)
GUISetState(@SW_SHOW,$gui)

While 1
    $m=GUIGetMsg()
    Select
    Case $m=$GUI_EVENT_CLOSE
        Exit
    Case $m=$ok
        $un=GUICtrlRead($un_ipt)
        $psw=GUICtrlRead($psw_ipt)
       
        $ie=_IECreate('https://www.lfs.net/?page=register')
        
        $oForms = _IEFormGetCollection($ie, 2)      ;Added
               
        ;$un_web=_IEGetObjByName($ie,'username')    ;Removed
        $un_web=_IEFormElementGetObjByName($oForms,'username')  ;Added
        $mail_web=_IEGetObjByName($ie,'email')
        $country_web=_IEGetObjByName($ie,'country')
        $hear_web=_IEGetObjByName($ie,'reference')
        $psw_web=_IEGetObjByName($ie,'pass')
        $psw2_web=_IEGetObjByName($ie,'passcheck')
       
        _IEFormElementSetValue($un_web,$un)
        _IEFormElementSetValue($psw_web,$psw)
        _IEFormElementSetValue($psw2_web,$psw)
    EndSelect
WEnd
Thank you VERY MUCH!!!!!!!!!!!!!

The script works greatly.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0