Jump to content

Help clicking on a form button onclick="Login();"

Recommended Posts

Hi all!

Been playing with autoscript for a while and even without a lot of knowledge in scripting/programming I'm managing to automate some stuff easily.

My problem now is that I have a login page where I need to input username/password in the respective forms, which is already done, and submit the form.

The problem is that the _IEFormSubmit does not work in this case, I think that's because there is javascript on the code (I am not even closer to experienced programmer so I maybe be saying something wrong)

Then I tried to simulate a click on the button with _IEAction but it's not working either ( _IEAction ($o_form, "click") )

Now I do not know what other options I have to send this form. Someone can help me out?

If needed I can post the code.


Link to post
Share on other sites
  • Moderators

Hi, troublie. Welcome to the forums. Posting your code is always a great idea. It will help us help you :)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to post
Share on other sites

#include <file.au3>
#include <ie.au3>

Global $o_IE, $o_form, $line, $text, $temp, $user, $pass, $oInputs, $oInput

;navigating to login page
$o_IE = _IECreate()
_IENavigate ($o_IE, "link")
_IEImgClick ($o_IE, "link/templates/public/images/an3.jpg", "src")
;finishing navigating to login page

; read username:password
$file = FileOpen(@ScriptDir & "Login.txt")
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
while 1
$line = FileReadLine ($file)
If @error = -1 Then ExitLoop
  $text = $line
  $temp = StringSplit($text,':',1)
  $user = $temp[1]
  $pass = $temp[2]
; end reading username:password

$o_form = _IEFormGetObjByName ($o_IE, "FrmLogin")
$o_user = _IEFormElementGetObjByName ($o_form, "mail")
_IEFormElementSetValue ($o_user, $temp[1])
$o_passw = _IEFormElementGetObjByName ($o_form, "password")
_IEFormElementSetValue ($o_passw, $temp[2])

now I am stuck in this part of the code. I have to click in the button "Entrar" which is

<input onclick="Login();" type="submit" value="Entrar"/>

As you can see I have no id or name I tried a lot of things to select this button and send ENTER or select this button and click with _ieaction but none worked.

edit: I do not want to do this with mouse coordinates or pixel detection!

Edited by troublie
Link to post
Share on other sites

thanks for the reply roshith.

it gave me this:

--> IE.au3 V2.4-0 Warning from function _IEFormElementGetObjByName, $_IEStatus_NoMatch

--> IE.au3 V2.4-0 Error from function _IEAction, $_IEStatus_InvalidDataType

I'm trying to get past this the whole day and nothing yet. Reading some forum posts I saw something with the _IETagNameGetCollection, but It gave me errors too.

edit: if I add this to the end of the code

For $oInput In $oInputs
    MsgBox(0, "Form Input Type", "Form: " & $oInput.form.name & " Type: " & $oInput.type)
If $o_form.type = "submit" Then
_IEAction ($o_form, "click")

it returns to me 1st: FmrLogin Type: text

then 2nd: FmrLogin Type: password

then 3rd: FmrLogin Type: submit

What code can I use to try to select this button or click it that have a index option and also type option?

Already tried before with a command that I do not remember right now and it not returned me any error, but at the same time did not logged in succefully, so it did not work.

Edited by troublie
Link to post
Share on other sites


Look at the _IEAction function in the help file. Dale Holmes provides a way to click a stubborn button. It has worked for me in the past.

Also, using _IEFormelementgetobjbyname does no good if there is no name property. You might try _IEgetobjbyid against the IE object.

Good Luck,


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...