Jump to content
Sign in to follow this  

newbie question about clicking a button in IE

Recommended Posts



I have been using autoit now for 2-3 months and I am having great success with it.

I am not a web guy, so this is a learning process, so bear with me - I have automated about 8 other websites I access and everything has been working fine up until now.

I am trying to automate a task, I am filling in a search element with "turtle" and clicking a button named "Search!", I am unable to click the "Search!" button, and I think it is because there is a hidden input type with the same name, but I really don't know how to verify it - here is the source in question

<input type="hidden" name="Submit" value="true">

<input type="submit" class="registerBtn" name="Submit" value="Search!">

here is my code:

_IENavigate($oIE, $URL)
$o_search = _IEGetObjByName($oIE, "search")
_IEFormElementSetValue($o_search, "turtle")
$o_searchButton = _IEGetObjByName($oIE, "Submit")
_IEAction($o_searchButton, "click")

I have ran into this problem before, and I used _IEFormGetCollection() and _IETagNameGetCollection() to go through all the input types and select whatever it was that i needed, exact code below:

#include <IE.au3>

$oIE = _IECreate("http://www.google.com")
Local $oForms = _IEFormGetCollection($oIE)
MsgBox(0, "Forms Info", "There are " & @extended & " forms on this page")
For $oForm In $oForms
MsgBox(0, "Form Info", $oForm.name)

$oInputs = _IETagNameGetCollection ($oIE, "input")
For $oInput In $oInputs
MsgBox(0, "Form Input Type", "Form: [" & $oInput.form.name & "] Type: [" & $oInput.type & "] Value: [" & $oInput.value & "] Name: [" & $oInput.type & "]")
If @error Then
MsgBox(0, "Error", @error)
; ExitLoop

However, for this particular website this code does not work, I put in the $URL for my site and I get :

>Running:(\Program Files\AutoIt3\autoit3.exe "G:\automation\scripts\learning\IE.Forms.au3"   
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
G:\automation\scripts\learning\IE.Forms.au3 (12) : ==> Variable must be of type "Object".:
MsgBox(0, "Form Input Type", "Form: [" & $oInput.form.name & "] Type: [" & $oInput.type & "] Value: [" & $oInput.value & "] Name: [" & $oInput.type & "]")
MsgBox(0, "Form Input Type", "Form: [" & $oInput.form^ ERROR

so it appears to me I can not cycle through all the input types and select the one I need? Any thoughts how I can get past this speed bump? I've been reading all I can for the past few days and I think I'm to the point of hurting that I don't mind asking for help :)

Share this post

Link to post
Share on other sites

Hi i am not a exper.

But i whas thinking maby you can make a script that is looping true all the form items and cicking on al of them on them.

After the click show a messages box whit the info you need to find this field.

Share this post

Link to post
Share on other sites

try this


I use it to see a sites code and get a general idea of how it works

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