muzle6074 Posted December 8, 2008 Posted December 8, 2008 $IE_Topic = $IE_Links.Item(24) _IENavigate($IE, $IE_Topic.href) If the page fails to load and the collection of links is not stored in $IE_Topic then _IENavigate throws an error. How can I prevent executing the _IENavigate from running if there is no collection of links in $IE_Topic? Regards --Alex
amokoura Posted December 8, 2008 Posted December 8, 2008 I presume the links object is a normal collection object. You could then use the Count property: if $IE_Links.Count = 0 then MsgBox(0,0,'Link count zero!') endif
muzle6074 Posted December 8, 2008 Author Posted December 8, 2008 Hi amokoura, I ran the script and canceled the page load to try replicate the error but this happened: The requested action with this object has failed.: If $IE_Links.Count = 0 Then If $IE_Links.Count ^ ERROR Code: $IE_Links = _IELinkGetCollection($IE) If $IE_Links.Count = 0 Then MsgBox(0, "", "No collection") EndIf $IE_Topic = $IE_Links.Item(24) _IENavigate($IE, $IE_Topic.href)
amokoura Posted December 8, 2008 Posted December 8, 2008 [...] ERROR [...] Code: $IE_Links = _IELinkGetCollection($IE) If $IE_Links.Count = 0 Then MsgBox(0, "", "No collection") EndIf $IE_Topic = $IE_Links.Item(24) _IENavigate($IE, $IE_Topic.href) OK I guess _IELinkGetCollection failed and didn't return any object at all. How about checking _IELinkGetCollection's errors (Check out from manual) before using its data.
furrycow Posted December 8, 2008 Posted December 8, 2008 From what i recall doing this a while back, when IE fails to load a webpage it finds three links; because of the help links - eg;troubleshoot connection (and then two others) Instant Lockerz Invite - www.instantlockerzinvite.co.uk
amokoura Posted December 8, 2008 Posted December 8, 2008 From what i recall doing this a while back, when IE fails to load a webpage it finds three links; because of the help links - eg;troubleshoot connection (and then two others)If it's true, the function should return a Collection object. Probably the Count property isn't set then.As the manual says, using @EXTENDED should also give the link count.But i don't know, error checking by evaluating the link count sounds tricky. Maybe the page should be checked some other way before going any deeper.
DaleHohm Posted December 8, 2008 Posted December 8, 2008 As mentioned above, see the helpfile for _IELinkGetCollection: Success: Returns an object collection of all links in the document, @EXTENDED = link count Failure: Returns 0 and sets @ERROR So, check @EXTENDED to see if it is > 0, check the return value (what you expect to be a collection) and see if it is 0 instead or is the IsObj check on the return value. You can also use _IEErrorHandlerRegister() which will trap the COM error and allow your script to continue. 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
muzle6074 Posted December 8, 2008 Author Posted December 8, 2008 From what i recall doing this a while back, when IE fails to load a webpage it finds three links; because of the help links - eg;troubleshoot connection (and then two others)After some quick testing it does return a small collection of items even if the page does not load.Thank you Dale I have used the code you suggested to test @extended.Thank you all for your contribution!Regards--Alex
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