Sign in to follow this  
Followers 0
guwguw

_IELinkGetCollection

8 posts in this topic

Allright,

the forum didn't allow a search for "single link by index", so I'll have to go this way.

_IELinkGetCollection says "Returns a collection object containing all links in the document or a single link by index."

My question: What syntax do I have to use to get the sixth link in a list of 19?

I tried

$oIE = _IEAttach ($wintitle1)
_IELoadWait ($oIE)

$oLinks = _IELinkGetCollection ($oIE)
$iNumLinks = @extended
MsgBox(0, "Link Info", $iNumLinks & " links found")
$counter = 0
For $oLink In $oLinks
    $counter += 1
    ConsoleWrite(@ScriptLineNumber & "Link Info # "& $counter &" " & $oLink.href)
Next
and get a list of 19 links.

But _IELinkGetCollection($oIE,6) does NOT return a value - what is the correct syntax?

Share this post


Link to post
Share on other sites



What are you wanting to do or know about the link once you find it?

_IELinkGetCollection($oIE,6) will not return a "value", but rather returns an object variable that references the link. That object then has properties like .href, .innerText etc.

Also, since indexes start numbering at 0, the sixth link would be index 5.

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

Share this post


Link to post
Share on other sites

What are you wanting to do or know about the link once you find it?

I want to extract a session_id, which is part of the URL. So I thought of stripping the rightmost part of the URL beginning with "&session_id=", once I figure out how to get the "sixth entry", lol.

_IELinkGetCollection($oIE,6) will not return a "value", but rather returns an object variable that references the link. That object then has properties like .href, .innerText etc.

Also, since indexes start numbering at 0, the sixth link would be index 5.

I kind of suspected that with 0 as starting value, but would have seen it at the first test ...

I'm pretty green/ignorant, where object oriented stuff is concerned, so I fail to understand why it doesn't print anything out, if I ask for the " object variable" ... I tried stuff like $oLinks[5] and such, but no success (syntax error).

The part $oLink.href made sense, but isn't there a direct way of picking number six in the list?

Additionally, where can I find a list of those "properties" for the _IE... stuff?

Share this post


Link to post
Share on other sites

The answer to your question is in the example you posted above...

$oLink = _IELinkGetCollection($oIE, 5)

$sHref = $oLink.href

For more information on the DOM, its properties, events and methods, goto MSDN -- see the links in my sig.

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

Share this post


Link to post
Share on other sites

Thanks Dale,

That was one combination I had not yet tried.

Results are as expected.

Share this post


Link to post
Share on other sites

Allright,

the forum didn't allow a search for "single link by index", so I'll have to go this way.

_IELinkGetCollection says "Returns a collection object containing all links in the document or a single link by index."

My question: What syntax do I have to use to get the sixth link in a list of 19?

I tried

$oIE = _IEAttach ($wintitle1)
_IELoadWait ($oIE)

$oLinks = _IELinkGetCollection ($oIE)
$iNumLinks = @extended
MsgBox(0, "Link Info", $iNumLinks & " links found")
$counter = 0
For $oLink In $oLinks
    $counter += 1
    ConsoleWrite(@ScriptLineNumber & "Link Info # "& $counter &" " & $oLink.href)
Next
and get a list of 19 links.

But _IELinkGetCollection($oIE,6) does NOT return a value - what is the correct syntax?

I would like to expand on this post.

I have variable links on a page but always want to clink on the last link. Would the following allow this.

$oLinks = _IELinkGetCollection ($oIE)

_IELinkClickByIndex($oIE,$oLinks)

Share this post


Link to post
Share on other sites

$oIE = _IECreate ("http://www.google.com")
$iNumLinks = @extended
MsgBox(0, "Link Info", $iNumLinks & " links found")
For $oLink In $oLinks
    MsgBox(0, "Link Info", $oLink.href)
Next
_IELinkClickByIndex($oIE, $iNumLinks - 1)

Just note that it $iNumLinks returns the number of links on a 1 based index, while _IELinkClickByIndex clicks on a 0 based index... hence the minus 1 to the _IELinkClickByIndex.


While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd

Share this post


Link to post
Share on other sites

I think you left out one line in your example

$oIE = _IECreate ("http://www.google.com")
$oLinks - _IELinkGetCollection($oIE) ; <---- oops
$iNumLinks = @extended
MsgBox(0, "Link Info", $iNumLinks & " links found")
For $oLink In $oLinks
    MsgBox(0, "Link Info", $oLink.href)
Next
_IELinkClickByIndex($oIE, $iNumLinks - 1)

:)


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

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