cypher175 Posted May 18, 2009 Share Posted May 18, 2009 How could I MsgBox all URL's of the links on a webpage that _IELinkGetCollection($IE) returns but in a Random Order though..?? The code below is what I got so far, but it seems to repeat some links more than once though..?? I just want it to MsgBox each link's URL only once but in random order though for every link on the webpage.. Whats wrong/missing in my code..?? $GetLinks = _IELinkGetCollection($IE) $NumLink = @extended For $INDEX = 1 To $NumLink $Random = Random(0,$NumLink,1) $Link = _IELinkGetCollection($IE, $Random) MsgBox(0,"",$Link.href) Next Link to comment Share on other sites More sharing options...
DaleHohm Posted May 20, 2009 Share Posted May 20, 2009 What possible reason do you have for doing this? Sounds like what you want is shuffled, not random. 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 More sharing options...
cypher175 Posted May 20, 2009 Author Share Posted May 20, 2009 How would i do it shuffled then..?? Link to comment Share on other sites More sharing options...
DaleHohm Posted May 20, 2009 Share Posted May 20, 2009 You were wise to remove your last reply. It made the difference between getting the example below and me telling you good luck, go take a class. Your lack of understanding of the two concepts is the reason your code fails. Random, the way you used it in your example is like tossing 20 darts at a dart board with your eyes closed and expecting to get each number only once. Shuffle is analygous to pulling 20 numbered balls out of a bag - you are guaranteed to get each number only once. What you need to do is to apply a random order to a fixed set. You can use the Random function in this exercise, but you need a level of indirection. The following example does this by applying a random ordering to an array with the same number of elements as you want to shuffle, then using that shuffled order to display your data: #include <IE.au3> #include <Array.au3> $oIE = _IECreate("www.autoitscript.com") $oLinks = _IELinkGetCollection($oIE) $NumLink = @extended Dim $aSet[$Numlink][2] For $i = 0 to $Numlink - 1 $aSet[$i][0] = $i $aSet[$i][1] = Random(0,1) Next _ArrayDisplay($aSet) _ArraySort($aSet, 0, 0, 0, 1) _ArrayDisplay($aSet) For $i = 0 to $Numlink - 1 $oLink = $oLinks.item($aSet[$i][0]) MsgBox(0,$oLink.innerText,$oLink.href) Next 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now