Sign in to follow this  
Followers 0
Numeric

Auto login on vBulletin forum

2 posts in this topic

#1 ·  Posted

Hello, I am both new to AutoIt and this forum, but have searched for the solution for an auto login method for over two hours now. Either I don't understand the use of the _IE functions or I just couldn't find it, assuming that there's already a solution publically available to my problem. The reason why I want to learn AutoIt is to countermeasure a (currently) active spambot. As I am a moderator on the forum, and the active admins lack time, I'd like to automate the post moderating and possible the ban system. But for me to do so, I'll have to login first, obviously.

Below is a part of the HTML source that hopefully contains all necessary information.

<table cellpadding="0" cellspacing="3" border="0">
    <tr>
        <td class="smallfont" style="white-space: nowrap;"><label for="navbar_username">User Name</label></td>
        <td><input type="text" class="bginput" style="font-size: 11px" name="vb_login_username" id="navbar_username" size="10" accesskey="u" tabindex="101" value="User Name" onfocus="if (this.value == 'User Name') this.value = '';"/></td>
        <td class="smallfont" nowrap="nowrap"><label for="cb_cookieuser_navbar"><input type="checkbox" name="cookieuser" value="1" tabindex="103" id="cb_cookieuser_navbar" accesskey="c"/>Remember Me?</label></td>
    </tr>
    <tr>
        <td class="smallfont"><label for="navbar_password">Password</label></td>
        <td><input type="password" class="bginput" style="font-size: 11px" name="vb_login_password" id="navbar_password" size="10" tabindex="102"/></td>
        <td><input type="submit" class="button" value="Log in" tabindex="104" title="Enter your username and password in the boxes provided to login, or click the 'register' button to create a profile for yourself." accesskey="s"/></td>
    </tr>
</table>

Below is the code I have so far. As described in the comments, the four solutions I have so far didn't work. Am I missing something, a function or wrong data maybe?

#include <IE.au3>

Global $oIE = _IECreate("FORUM")

Local $username = _IEGetObjByName($oIE, "vb_login_username")
Local $password = _IEGetObjByName($oIE, "vb_login_password")

_IEFormElementSetValue($username, "USERNAME")
_IEFormElementSetValue($password, "PASSWORD")

;Everything above works just fine, being that everything CAPITALISED is filled out correctly

;Solution 1 (doesn't work)
;Getting the name of the object (unsure, is it "Sumbit"?)
Local $oButton1 = _IEGetObjByName($oIE, "Submit")
_IEAction ($oButton1, "click")

;Solution 2 (doesn't work)
;Unsure what it does precicely, but getting the link of the button
Local $oButton2 = _IELinkGetCollection($oIE, 104)
_IEAction ($oButton2, "click")

;Solution 3 (doesn't work)
;I assume it's to get the tabindex of the button
Local $oButton3 = _IELinkClickByIndex ($oIE, 104)
_IEAction($oButton3, "click")

;Solution 4 (doesn't work)
;I assume this clicks on all the forms available on the page
Local $oForms = _IEFormGetCollection($oIE)
Local $iNumForms = @extended
Local $oForm
For $i = 0 To $iNumForms - 1
    $oForm = _IEFormGetCollection($oIE, $i)
    _IEAction($oForm, "click")
Next

Does anyone know the solution to this problem? The problem being that I can't automate the login process.


Student Mechatronics • Robotica • C++

Share this post


Link to post
Share on other sites



#2 ·  Posted

#cs
<table cellpadding="0" cellspacing="3" border="0">
    <tr>
        <td class="smallfont" style="white-space: nowrap;"><label for="navbar_username">User Name</label></td>
        <td><input type="text" class="bginput" style="font-size: 11px" name="vb_login_username" id="navbar_username" size="10" accesskey="u" tabindex="101" value="User Name" onfocus="if (this.value == 'User Name') this.value = '';"/></td>
        <td class="smallfont" nowrap="nowrap"><label for="cb_cookieuser_navbar"><input type="checkbox" name="cookieuser" value="1" tabindex="103" id="cb_cookieuser_navbar" accesskey="c"/>Remember Me?</label></td>
    </tr>
    <tr>
        <td class="smallfont"><label for="navbar_password">Password</label></td>
        <td><input type="password" class="bginput" style="font-size: 11px" name="vb_login_password" id="navbar_password" size="10" tabindex="102"/></td>
        <td><input type="submit" class="button" value="Log in" tabindex="104" title="Enter your username and password in the boxes provided to login, or click the 'register' button to create a profile for yourself." accesskey="s"/></td>
    </tr>
</table>
#ce
$sSource = FileRead(@ScriptFullPath)
$sStart = "<table"
$iStart = StringInStr($sSource, $sStart, 1)
$sEnd = "</table>"
$iEnd = StringInStr($sSource, $sEnd, 1)

#include <IE.au3>

Global $oIE = _IECreate()
_IEBodyWriteHTML($oIE, StringMid($sSource, $iStart, $iEnd-$iStart+StringLen($sEnd)))

Local $username = _IEGetObjByName($oIE, "vb_login_username")
Local $password = _IEGetObjByName($oIE, "vb_login_password")

_IEFormElementSetValue($username, "USERNAME")
_IEFormElementSetValue($password, "PASSWORD")

Execute('($password.parentNode.parentNode.getElementsByTagName("input"))(1).click()');how to click
MsgBox(0, "", Execute('($password.parentNode.parentNode.getElementsByTagName("input"))(1).value'));to show the button was selected

 

1 person likes this

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