Jump to content

How to get id or name in _IE


Recommended Posts

Hey

I'm writing some program, and I need auto login.

$OdpriIE = _IECreate("http://ikariam.si", 0, 1, 1, 1)
$_Uporabnik = _IEGetObjById($OdpriIE, "login")
If IsObj($_Uporabnik) Then $_Uporabnik.value = $Uporabnik
$_Pw = _IEGetObjById($OdpriIE, "pwd")
If IsObj($_Pw) Then $_Pw.value = $Pw

The variables Uporabnik, Pw ... are defined before this code. Now here it fill in login name and password. I want now to press on Login button, this must look like this:

$Potrdi = _IEGetObjByName($OdpriIE, "What must be here??!")
If ISObj($Potrdi) Then $Potrdi.click

But hell I cant get ID or name of this button, here is how its look on web:

<td><input id="login" name="name" type="text" class="login" /></td>
                    <td><input id="pwd"  name="password" type="password" class="pass" /></td>
                    <td><input type="submit" class="button" value="Login" /></td>

Are there some other options to do that (not mouse click) or what can I do ...

Edited by DoctorSLO
Link to comment
Share on other sites

Its not work :)

Here is all html code:

<form id="loginForm" name="loginForm" action="#" onsubmit="changeAction('login');" method="post">
        <div id="formz">
            <table cellpadding="0" cellspacing="0" id="logindata">
                <tr>
                    <td><label for="welt" class="labelwelt">Svet</label></td>
                    <td><label for="login" class="labellogin">Ime igralca</label></td>
                    <td><label for="pwd" class="labelpwd">Geslo</label></td>
                    <td></td>
                </tr>
                <tr>
                    <td>
                        <select id="universe" class="uni" size="1">
                            <option value="s1.ikariam.si">Alpha</option>
                        </select>
                    </td>
                    <td><input id="login" name="name" type="text" class="login" /></td>
                    <td><input id="pwd"  name="password" type="password" class="pass" /></td>
                    <td><input type="submit" class="button" value="Login" /></td>
               </tr>
               <tr>
                    <td colspan="3" class="forgotpwd"><a href="lostpwd.php" title="Tukaj lahko zahtevate novo geslo">Ste pozabili geslo?</a></td>
                    <td style="font-size:10px; text-align:left; padding:4px 0px 0px 16px;">
                        S prijavo sprejmem<br />
                        <a style="color:#DF5843; margin-left:0px;" target="_blank" class="footerlink" href="http://impressum.gameforge.de/index.php?lang=si&amp;art=tac&amp;special=&amp;&f_text=000000&amp;f_text_hover=804000&amp;f_text_h=9ebde4&amp;f_text_hr=DED3B9&amp;f_text_hrbg=DED3B9&amp;f_text_hrborder=804000&amp;f_text_font=verdana%2C+arial%2C+helvetica%2C+sans-serif&amp;f_bg=DED3B9">Pogoji Uporabe</a>.
                    </td>
               </tr>
           </table>
        </div>
    </form>

And here is my code:

$OdpriIE = _IECreate("http://ikariam.si", 0, 1, 1, 1)
$Form = _IEFormGetObjByName ($OdpriIE, "loginForm")
$_Uporabnik = _IEFormElementGetObjByName($OdpriIE, "name")
$_Pw = _IEFormElementGetObjByName($OdpriIE, "password")
_IEFormElementSetValue ($_Uporabnik, $Uporabnik)
_IEFormElementSetValue ($_Pw, $Pw)
_IEFormSubmit ($Form)

errors

$_IEStatus_InvalidObjectType

Edited by DoctorSLO
Link to comment
Share on other sites

The only think that its work is this :

$OdpriIE = _IECreate("http://ikariam.si", 0, 1, 1, 1)
$Form = _IEFormGetObjByName ($OdpriIE, "loginForm")
$_Uporabnik = _IEGetObjById($OdpriIE, "login")
If IsObj($_Uporabnik) Then $_Uporabnik.value = $Uporabnik
$_Pw = _IEGetObjById($OdpriIE, "pwd")
If IsObj($_Pw) Then $_Pw.value = $Pw
    Sleep(2000)
_IEFormSubmit($Form)

It fills Username and Password, and after 2 sec something do, I dont know what (like refresh), and the Username and PW gone form IE login.

Link to comment
Share on other sites

$OdpriIE = _IECreate("http://ikariam.si", 0, 1, 1, 1)
$Form = _IEFormGetObjByName ($OdpriIE, "loginForm")
$_Uporabnik = _IEFormElementGetObjByName($Form, "name")
$_Pw = _IEFormElementGetObjByName($Form, "password")
_IEFormElementSetValue ($_Uporabnik, "PLACE USER NAME")
_IEFormElementSetValue ($_Pw, "PLACE PASSWORD")
_IEFormSubmit ($Form)

Edited by TerarinK

0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

Link to comment
Share on other sites

#include <IE.au3> 
$Uporabnik = "test"
$Pw = "test"

$OdpriIE = _IECreate("http://ikariam.si", 0, 1, 1, 1)
$Form = _IEFormGetObjByName($OdpriIE, "loginForm")
$_Uporabnik = _IEFormElementGetObjByName($Form, "name")
$_Pw = _IEFormElementGetObjByName($Form, "password")
_IEFormElementSetValue($_Uporabnik, $Uporabnik)
_IEFormElementSetValue($_Pw, $Pw)
_IEFormSubmit($Form)

Link to comment
Share on other sites

Uf, finally, here is code that I was needed :) THX all for help

#include <IE.au3>
$Uporabnik = "test"
$Pw = "test"

$OdpriIE = _IECreate("http://ikariam.si/", 0, 1, 1, 1)
$Form = _IEFormGetObjByName($OdpriIE, "loginForm")
$oElements = _IETagNameGetCollection ($OdpriIE, "input")
$_Uporabnik = _IEFormElementGetObjByName($Form, "name")
$_Pw = _IEFormElementGetObjByName($Form, "password")
_IEFormElementSetValue($_Uporabnik, $Uporabnik)
_IEFormElementSetValue($_Pw, $Pw)
Sleep(1000)
For $oElement In $oElements
    If String($oElement.value) = "Login" Then
        _IEAction($oElement, "Click")
    EndIf
    Next
Exit
Link to comment
Share on other sites

You beat me at putting that up there first but here is another one to include

#include <IE.au3> 
Dim $sName = "Test", $sPassword = "Test"
$oIE = _IECreate("http://ikariam.si", 0, 1, 1, 1)
_Logon($oIE)

Func _Logon(ByRef $oObject)
    If Not IsObj($oObject) Then
        MsgBox(0, "Not Found", "No $oObject")
        SetError(1)
        Return -1
    EndIf
    
    $oElements = _IETagNameAllGetCollection($oObject)
    For $oElement In $oElements
        If StringInStr($oElement.Tagname, "Input") Then
            If StringInStr($oElement.Id, "login") Then
                $oEmail = $oElement
            ElseIf StringInStr($oElement.Id, "pwd") Then
                $oPassword = $oElement
            EndIf
        EndIf
    Next    

    _IEFormElementSetValue($oEmail, $sName)
    _IEFormElementSetValue($oPassword, $sPassword)

    _IEAction ($oPassword, "focus")
    
    ControlSend($oObject, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")
    _IELoadWait($oObject)       
    Return 1
EndFunc

Use whatever one fits your liking

0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

Link to comment
Share on other sites

  • 3 weeks later...

its possible to make it for check box? for agree terms?

thanx, Matys

Dog ate your help file? :)

_IEFormElementCheckBoxSelect()

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...