Jump to content

_IELinkGetCollection - How to get to any link other than the first one in the collection?


Recommended Posts

Hey Guys,

Can anyone tell me how to get to the second link in the collection? I don't understand this function too well. From what I understand it makes an array where entry 1) will be the first link and 2) the second and so forth, but I am unsure how to get to anything other than the first link in the collection.

Thanks for any help.

Neoborn

~Projects~1. iPod Ejector 1.0 - Tool Used To Eject iPod in Windows - Uses DevEject.exe :P2. SmartFTP Close Popup Tool - Closes reminders from freeware SmartFTP.~Helpful Links For New Users~1. LXP's Learning AutoIT PDF Guide - <<< Go here for a PDF Guide on learning AutoIT from the ground up!<<<2. AutoIt 1-2-3 <<<Want to learn more about AutoIT quickly? Go Here<<<3. How To Install The Beta And Production Versions Of AutoIT / SciteAutoIT

Link to comment
Share on other sites

The first link reference would be _IELinkGetCollection($oIE, 0) the second _IELinkGetCollection($oIE, 1) The function's second parameter is a 0-based index.

Note that a collection is similar to an array in some ways, but it is not an array. The example for this function demonstrates how to loop through the collection.

Dale

Edit: typos

Edited by DaleHohm

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 then if I wanted to click on a certain link in the index then I would first get the collection and then use the command for clicking the link by index? i.e.:

_IELinkGetCollection ( ByRef $o_object [, $i_index = -1] )

_IELinkClickByIndex ( ByRef $o_object, $i_index [, $f_wait = 1] )

The $i_index variable would be the number of the link I would like to click in the collection yes?

Thanks, am just learning this.

Also what if I want to click on a form without a name ie the submit button has no name. How do I do a form collection and then just submit by index form 5 or whatever?

Edited by Neoborn

~Projects~1. iPod Ejector 1.0 - Tool Used To Eject iPod in Windows - Uses DevEject.exe :P2. SmartFTP Close Popup Tool - Closes reminders from freeware SmartFTP.~Helpful Links For New Users~1. LXP's Learning AutoIT PDF Guide - <<< Go here for a PDF Guide on learning AutoIT from the ground up!<<<2. AutoIt 1-2-3 <<<Want to learn more about AutoIT quickly? Go Here<<<3. How To Install The Beta And Production Versions Of AutoIT / SciteAutoIT

Link to comment
Share on other sites

If you want to click on a link by index, there is no need to get the collection first - just use _IELinkClickByIndex

For forms, either use _IEFormSubmit or use _IEFormElementGetCollection specifying the correct index and then use _IEAction($oSubmit, "click")

Please try the examples in the helpfile.

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

If anyone can answer these questions that would be great:

1. If you are using the link indexing how do you know what number link you want to execute?

2. What is a collection object? How does a collection object work internally? How do you use the information that is in the collection? When would you use a collection? ( Yes I have read some of the help file examples but need more information.

3. I am using the following code ( taken from a thread here somewhere ) to search for links on a page that contain a common address i.e.

Func SearchLinks()
_IELoadWait($oIE)
$oLinks = _IELinkGetCollection ($oIE)
$sHref = "http://www.somewebsite.org/forums/showthread.php?"
For $oLink In $oLinks
    If StringInStr(String($oLink.href), $sHref) Then ; Force String just in case you hit a null value
        _IEAction($oLink, "click")
    ExitLoop
    EndIf
Next
EndFunc

So it finds all the links with that address, so then I am going to execute the first link it finds, then once I have posted I wanted it to click on the second link in the "collection???" or "index", how do I do that? I think the confusion I have is how to obtain the links, then sequentially go through them one by one executing them.

Any help is appreciated, also I'm sorry if this isn't explained well enough but I am doing my best.

~Projects~1. iPod Ejector 1.0 - Tool Used To Eject iPod in Windows - Uses DevEject.exe :P2. SmartFTP Close Popup Tool - Closes reminders from freeware SmartFTP.~Helpful Links For New Users~1. LXP's Learning AutoIT PDF Guide - <<< Go here for a PDF Guide on learning AutoIT from the ground up!<<<2. AutoIt 1-2-3 <<<Want to learn more about AutoIT quickly? Go Here<<<3. How To Install The Beta And Production Versions Of AutoIT / SciteAutoIT

Link to comment
Share on other sites

bump

~Projects~1. iPod Ejector 1.0 - Tool Used To Eject iPod in Windows - Uses DevEject.exe :P2. SmartFTP Close Popup Tool - Closes reminders from freeware SmartFTP.~Helpful Links For New Users~1. LXP's Learning AutoIT PDF Guide - <<< Go here for a PDF Guide on learning AutoIT from the ground up!<<<2. AutoIt 1-2-3 <<<Want to learn more about AutoIT quickly? Go Here<<<3. How To Install The Beta And Production Versions Of AutoIT / SciteAutoIT

Link to comment
Share on other sites

In object-oriented programming, a collection object is a single variable that contains a collection of object variables. Both the collection object and the individual objects contained have properties and methods. Because it holds more than one object variable it is similar to an array, but you must handle it much differently.

The example that you included actually answers the first question that you asked. The example loops through the elements in a collection object using a for...next construct. A link object as many properties that you can examine in the same way that the example shows. To learn more about these properties you'll need to reference the documentation in MSDN -- please see my signature.

Regarding your second question, please understand that if clicking on a link causes the browser to refresh or move to a new page, the original link collection is no longer valid and you will have to reestablish it.

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