Sign in to follow this  
Followers 0
cag8f

Beginner using object identifiers

3 posts in this topic

I'm trying to understand object identifiers using the simple Internet Explorer example included with the AutoIt installation:

; *******************************************************
; Example 1 - Open a browser with the "form" example, get a reference
;               to the submit button by name and "click" it. This technique
;               of submitting forms is useful because many forms rely on Javascript
;               code and "onclick" events on their submit button making _IEFormSubmit()
;               not perform as expected
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("form")
$oSubmit = _IEGetObjByName ($oIE, "submitExample")
_IEAction ($oSubmit, "click")
_IELoadWait ($oIE)

; *******************************************************

This example works correctly when I run it, but I am having problems understanding the line:

$oSubmit = _IEGetObjByName ($oIE, "submitExample")

I can see that "submitExample" refers to the "Submit" button on the form. But if I'm trying to use this function on another web form, how do I determine the identifier for its "Submit" button (or any other buttons/objects)? I thought that using the Autoit Window Info tool on the example form would illuminate this, but when I hovered over the "Submit" button, I could not find the term "submitExample" anywhere. Furthermore, the ID field in the Autoit Window Info tool is blank when I hover over the "Submit" button, so I am having problems using _IEGetObjByID.

Thanks in advance.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

In the case of IE, the COM interface connects you to the Document Object Model (DOM) of the html document. Within that document is an element with an .id or .name property of "submitExample". You would see that element beforehand by using a DOM Inspector, like DebugBar. Or, for a simple page like that one, just View\Source on the IE toolbar. Scan the resulting HTML code and you'll find something like this:

<input name='submitExample' type='submit' value='Submit'>

That's the element you get an object reference to with your _IEGetObjByName() call.

The AutoIt Window Info Tool can't see the objects inside the DOM and can't help you there.

:)

Edited by PsaltyDS

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

Share this post


Link to post
Share on other sites

OK thanks--that is very helpful.

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