Jump to content

Need help with IE Form Element


Recommended Posts

I'm unable to fill the following form at:

http://www.meteonetwork.it/index.php?sezione=riservata

#include <IE.au3>
$oIE = _IECreate("http://www.meteonetwork.it/index.php?sezione=riservata")

; get pointers to the login form and username and password fields
$o_form = _IEFormGetObjByName($oIE, "1")
$o_login = _IEFormElementGetObjByName($o_form, "username")
$o_password = _IEFormElementGetObjByName($o_form, "password")

; Set field values and submit the form
_IEFormElementSetValue($o_login, "myusernamehere")
_IEFormElementSetValue($o_password, "mypasswordhere")

;~ Sleep(2000)

_IEFormSubmit($o_form)



Exit

I believe the problem is because the form has no name, lot's of forum serch but I'm unable to made the script work...

Any help really appreciated, thanks!

Link to comment
Share on other sites

  • Moderators

The form you are using doesn't have a name or an ID, look at _IEFormGetCollection().

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

The form you are using doesn't have a name or an ID, look at _IEFormGetCollection().

Thanks for your help, I read the _IEFormGetCollection() description, but I'm too dumb to adapt the sample code to suit my need. :):):)

Here my second not working attempt

#include <IE.au3>
    $USERNAME = 'myusername'
    $PASSWORD = 'mypassword'
    $oIE = _IECreate ("http://www.meteonetwork.it/index.php?sezione=riservata",0,1,1)
    $oForm = _IEFormGetCollection ($oIE, 0)
    $oLogin = _IEFormElementGetObjByName($oForm, "username")
    $oPass = _IEFormElementGetObjByName($oForm,"password")
    _IEFormElementGetObjByName($oLogin,"username")
    _IEFormElementGetObjByName($oPass,"password")
    _IEFormElementSetValue($oLogin,$USERNAME)
    _IEFormElementSetValue($oPass,$PASSWORD)
    _IEFormSubmit($oForm)

Any further help greatly appreciated, thanks again!

Edited by MarioX
Link to comment
Share on other sites

A little help

;<input type="password" name="password" size="20" maxlength="50">

;<input type="text" name="username" size="20" maxlength="50">

Login buton:

;<input type="submit" name="login" value="Login">

i think you need

#include <IE.au3>

;<input type="password" name="password" size="20" maxlength="50">

;<input type="text" name="username" size="20" maxlength="50">

;<input type="submit" name="login" value="Login">

$oIE = _IECreate ("http://www.meteonetwork.it/index.php?sezione=riservata")

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

$o2Form = _IEFormGetObjByName ($oIE, "password")

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

_IEFormElementSetValue ($oForm, "user")

_IEFormElementSetValue ($o2Form, "pass")

_IEFormSubmit ($oForm)

_IEFormSubmit ($o2Form)

but maybe there is no warning - wrong pass

Edited by usmiv4o

I have nothing to be proud: I am Bulgarian :~But there is no better place than 127.0.0.1Tutorial for newbies

Link to comment
Share on other sites

Thanks for your suggestion, but unfortunatly it not work, I get the following error while running the script from SCITE editor

--> IE.au3 Warning from function _IEFormGetObjByName, $_IEStatus_NoMatch

--> IE.au3 Warning from function _IEFormGetObjByName, $_IEStatus_NoMatch

--> IE.au3 Error from function _IEFormElementGetObjByName, $_IEStatus_InvalidDataType

--> IE.au3 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType

--> IE.au3 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType

--> IE.au3 Error from function _IEFormSubmit, $_IEStatus_InvalidDataType

--> IE.au3 Error from function _IEFormSubmit, $_IEStatus_InvalidDataType

Any idea what's wrong ?

Edited by MarioX
Link to comment
Share on other sites

  • Moderators

#include <IE.au3>
    $USERNAME = 'myusername'
    $PASSWORD = 'mypassword'
    $oIE = _IECreate ("http://www.meteonetwork.it/index.php?sezione=riservata")
    $oPass = _IEGetObjByName($oIE, 'password')
    $oLogin = _IEGetObjByName($oIE, 'username')
    _IEFormElementSetValue($oLogin,$USERNAME)
    _IEFormElementSetValue($oPass,$PASSWORD)
    _IEFormSubmit($oForm)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

#include <IE.au3>
    $USERNAME = 'myusername'
    $PASSWORD = 'mypassword'
    $oIE = _IECreate ("http://www.meteonetwork.it/index.php?sezione=riservata")
    $oPass = _IEGetObjByName($oIE, 'password')
    $oLogin = _IEGetObjByName($oIE, 'username')
    _IEFormElementSetValue($oLogin,$USERNAME)
    _IEFormElementSetValue($oPass,$PASSWORD)
    _IEFormSubmit($oForm)
Thanks for your code! It almost work, both form field are now filled.

There is a problem whith _IEFormSubmit, I get the following error

C:\form1.au3(11,25) : WARNING: $oForm: possibly used before declaration.

_IEFormSubmit($oForm)

~~~~~~~~~~~~~~~~~~~~~~~~^

C:\form1.au3(11,25) : ERROR: $oForm: undeclared global variable.

_IEFormSubmit($oForm)

~~~~~~~~~~~~~~~~~~~~~~~~^

C:\form1.au3 - 1 error(s), 1 warning(s)

Link to comment
Share on other sites

  • Moderators

Thanks for your code! It almost work, both form field are now filled.

There is a problem whith _IEFormSubmit, I get the following error

C:\form1.au3(11,25) : WARNING: $oForm: possibly used before declaration.

_IEFormSubmit($oForm)

~~~~~~~~~~~~~~~~~~~~~~~~^

C:\form1.au3(11,25) : ERROR: $oForm: undeclared global variable.

_IEFormSubmit($oForm)

~~~~~~~~~~~~~~~~~~~~~~~~^

C:\form1.au3 - 1 error(s), 1 warning(s)

That's because I never did that, I just commented it out in my code... do you see a $oForm variable other than _IEFormSubmit? A suggestion would be _IELinkClickByText() or _IEAction()

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I added the following code:

$oSubmit = _IEGetObjByName ($oIE, "login")
    _IEAction ($oSubmit, "click")
    _IELoadWait ($oIE)

The complete working code is:

#include <IE.au3>
    
    $USERNAME = 'myusername'
    $PASSWORD = 'mypassword'
    $oForm = 'login'
    $oIE = _IECreate ("http://www.meteonetwork.it/index.php?sezione=riservata")
    $oPass = _IEGetObjByName($oIE, 'password')
    $oLogin = _IEGetObjByName($oIE, 'username')
    $oSubmit = _IEGetObjByName ($oIE, "login")
    _IEFormElementSetValue($oLogin,$USERNAME)
    _IEFormElementSetValue($oPass,$PASSWORD)      
    _IEAction ($oSubmit, "click")
    _IELoadWait ($oIE)

Thanks all for help me!

Link to comment
Share on other sites

Hey, any ideas how to change the setup when the page is sending a hidden name for the field? Like this:

<td><input class="submit" type="submit" value="Log In" /></td>

</tr>

</table>

</div>

<input type="hidden" name="action" value="log_in" />

Link to comment
Share on other sites

  • Moderators

Hey, any ideas how to change the setup when the page is sending a hidden name for the field? Like this:

<td><input class="submit" type="submit" value="Log In" /></td>

</tr>

</table>

</div>

<input type="hidden" name="action" value="log_in" />

The name is not hidden the actual element is. I'm not sure what you mean by "change the setup".
Link to comment
Share on other sites

The name is not hidden the actual element is. I'm not sure what you mean by "change the setup".

Hey BigDaddy! Thanks for the reply. Sorry, I didn't get the element I should be using on your reply.

Just as an example: http://thecrosscog.com/churchpics/admin/ This is one of my websites and I am not trying to plug it but for example if you look at the source code you will see:

<form action="plog-upload.php" method="post">

<div align="center">

<table width="380">

<tr>

</tr>

<tr>

<td><label for="username"><b>Username:</b></label></td>

<td><input type="text" name="username" id="username" /></td>

</tr>

<tr>

<td><label for="password"><b>Password:</b></label></td>

<td><input type="password" name="password" id="password" /></td>

</tr>

<tr>

<td>&nbsp;</td>

<td><input class="submit" type="submit" value="Log In" /></td>

</tr>

</table>

</div>

<input type="hidden" name="action" value="log_in" />

</form>

inside my form the name for the submit element has been hidden to prevent bots from hitting it so easily. Can I use a different element here to have this login work on it. I can't make MarioX's Code work when this method is used. How can I make MarioX's Code log into this for me?

Thank You..

Link to comment
Share on other sites

  • Moderators

This works for me...

#include <IE.au3>

$sURL = "http://thecrosscog.com/churchpics/admin/"
$sUsername = "test"
$sPassword = "test"

$oIE = _IECreate($sURL)
$oForm = _IEFormGetCollection($oIE, 0)
$oUsername = _IEFormElementGetObjByName($oForm, "username")
$oPassword = _IEFormElementGetObjByName($oForm, "password")

_IEFormElementSetValue($oUsername, $sUsername)
_IEFormElementSetValue($oPassword, $sPassword)
_IEFormSubmit($oForm)
Link to comment
Share on other sites

Cool Big_daddy! That works for me. I couldn't get over that obstacle. Haha, looked at your pic.. Not at all what I expected.. LOL We have a Big Daddy's BarBQ here in Tulsa and He is what comes to mind with the name.. A rather large older gent.

Thanks for your help...

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...