Jump to content

_IEGetObjByName Problem


Recommended Posts

Hi Snipez,

I wanted to do a little program like many before:

A little script, that's able to insert text to a webpage. As a little warmup with IE.au3 I thought, I could try a read-from-website script.

My problem is to get the IDs! I tried names and IDs from the HTML code of the site, but this didnt work.

A little hint would be nice... :P

Greetingz from sunny bavaria!

Yes, I am a noob! But at least I try to learn!Moddingtech.de - Home of the german Modding-Scene!
Link to comment
Share on other sites

So a hint would be to please work through some of the examples in the helpfile.

If you are still having trouble, post some code and a site accessible on the internet for testing.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

So a hint would be to please work through some of the examples in the helpfile.

If you are still having trouble, post some code and a site accessible on the internet for testing.

Dale

Hm, I downloaded the help before, but there is no example for _IEGetObjByName. :P

Edited by Earthquake
Yes, I am a noob! But at least I try to learn!Moddingtech.de - Home of the german Modding-Scene!
Link to comment
Share on other sites

Hm, I downloaded the help before, but there is no example for _IEGetObjByName. :P

you don't need to download the helpfile. You need to install the latest production version of AutoIt and find User Defined Functions -> IE Management -> _IEGetObjByName in the production helpfile in your start menu under AutoIt3.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

This is an interesting experiement. You would think that given the following confusing html:

<input id=dog name=cat value=input1>
<input id=cat name=dog value=input2>

That getElementById('dog') would return the first one, and getElementById('cat') would return the second one. But they don't! They both return the first one. Very strange. We can prove this as follows. Save the above code into "confusing.htm" and create an au3 file in the same folder containing this code:

#include <IE.au3> 
$oIE = _IECreate (@scriptdir & "\confusing.htm")

msgbox(0,"By ID dog:",$oIE.document.getElementById('dog').value)
msgbox(0,"By ID cat:",$oIE.document.getElementById('cat').value)

for $input in $oIE.document.getElementsByTagName('input')
    if $input.name = "dog" then msgbox(0,"By NAME dog:",$input.value)
    if $input.name = "cat" then msgbox(0,"By NAME cat:",$input.value)
next

You'll see that the first two commands return the first element even though they have different IDs. The second bit loops through all of the Inputs in the document. and checks their names. (It could check their IDs instead, but I am looking to provide an answer to the original question.

I'll have to rethink how I use getElementById in the future, as it seems to accept the first element with an id OR name that match.

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

This is an interesting experiement. You would think that given the following confusing html:

I'm puzzled why you posted this in this thread, but you are correct... ID and NAME share the same namespace -- this is not just in IE by the way.

I agree that it can be confusing but it can be convenient as well...

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

I posted because I was personally interested in how to select an element by just it's name and NOT it's ID, and I was suprised at how difficult it turned out to be if there's a conflict such as this.

Perhaps I'm not helping Earthquake with his problem, but I thought my results noteworthy anway. I'm sorry. I didn't mean to step on anyone's toes or speak out of turn.

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

No toes damaged, but old posts are referenced extensively in this forum and posting off-topic makes information much harder to find.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

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