CRSounds Posted October 29, 2009 Posted October 29, 2009 Hi All, This is my first time posting, so I hope you forgive me if I step on any toes. I did a search for help with this and did not come up with anything relevant. The error I am receiving is: "IE.au3 V2.4-0 Error from function _IETagNameAllGetCollection, $_IEStatus_InvalidObjectType". It occurs when I run the following code. The code simply tries to extract an artist name and song title from an XM Radio web page and do so periodically (as the songs change). Any and all help is appreciated. #include <IE.au3> ;The purpose of this script is to continously get the current artist and track name ;for transmission to another device that is listening to a standalone XM radio receiver ;turn off image downloads to allow text portion of page to load faster $sIERegImg = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main","Display Inline Images") ;get current setting for image download RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main","Display Inline Images","REG_SZ","no") ;turn off images in downloads $temp=0 ;just a temp variable $oIE = _IECreate("http://www.xmradio.com/onxm/channelpage.xmc?ch=25",1,0,1,1);dont try to attach(0), hide browser window(0), wait for page to load(1), bring window into focus(1) $oDiv = _IEGetObjById ($oIE, "on-xm-pad-data") ;on-xm-pad-data is the ID for the artist + Song name data $oChanName = _IEGetObjById ($oIE, "channel-nav") While 1 $oElements = _IETagNameAllGetCollection ($oChanName) ;get all elements from the channel-nav level $oCount = @extended ;ConsoleWrite("Number of Elements is " & $oCount & @CR) ;just get the number of elements within this collection $oElement = _IETagNameAllGetCollection ($oChanName,0) ;channel is the 0th element returned ConsoleWrite("Channel is " & $oElement.innerText & @CR) $oElement = _IETagNameAllGetCollection ($oChanName,6) ;station is the 6th element returned (rel 0) ConsoleWrite("Station is """ & $oElement.innerText & """" & @CR) ConsoleWrite(" ARTIST - TITLE" & @CR & _IEPropertyGet($oDiv, "innertext") & @CR) ;print the artist and title on the line below this _IEAction($oIE,"refresh") ;refresh the page _IELoadWait ($oIE) Sleep(5000) if $temp > 200 then ExitLoop $temp = $temp + 1 ; _IEQuit ($oIE) ;closes browser session (but doing this takes a long time between iterations because the browser has to load again) WEnd _IEQuit ($oIE) ;closes browser session RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main","Display Inline Images","REG_SZ",$sIERegImg) ;reset IE image setting to original Regards CR
DaleHohm Posted October 29, 2009 Posted October 29, 2009 "IE.au3 V2.4-0 Error from function _IETagNameAllGetCollection, $_IEStatus_InvalidObjectType" When IE.au3 checks for errors like thi one, it checks first to see if the variable is an object and then if it is the right type of object... in this case it checks to see if it is an IE object (that it can drill into to get a document object), a document or a document element. It passed the initial object test and failed the second test in this case. It doesn't seem to make much sense that it would fail the second test looking at your code, so I'll suggest that you likely have a page that is releading on its own and is invalidating objects as we try to examine them. My suggestion would be that you use _IEErrorHandlerRegister() to allow you to make such errors non-fatal and allow you to trap the condition on your own and retry. Some additional use of _IELoadWait() may also be in order to again try to insure the page is quiescent. 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
CRSounds Posted October 30, 2009 Author Posted October 30, 2009 Hi Dale, Thanks for the help. When I looked at the code again I started to juggle lines that were in the loop against those that were out of the loop. Not sure why this worked but here is my follow up which is working now. Hopefully someone else can benefit from my lesson learned. Thanks for your help, and the great work on IE.AU3 Regards Carlton #include <IE.au3> ;The purpose of this script is to continously get the current artist and track name ;for transmission to another device that is listening to a standalone XM radio receiver ;turn off image downloads to allow text portion of page to load faster $sIERegImg = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main","Display Inline Images") ;get current setting for image download RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main","Display Inline Images","REG_SZ","no") ;turn off images in downloads $temp=0 ;just a temp variable $oIE = _IECreate("http://www.xmradio.com/onxm/channelpage.xmc?ch=25",1,0,1,1);dont try to attach(0), hide browser window(0), wait for page to load(1), bring window into focus(1) While $temp < 200 ;loop for some arbitrary number of times $oChanName = _IEGetObjById ($oIE, "channel-nav") $oDiv = _IEGetObjById ($oIE, "on-xm-pad-data") ;on-xm-pad-data is the ID for the artist + Song name data $oElements = _IETagNameAllGetCollection ($oChanName) ;get all elements from the channel-nav level $oCount = @extended ;ConsoleWrite("Number of Elements is " & $oCount & @CR) ;just get the number of elements within this collection $oElement = _IETagNameAllGetCollection ($oChanName,0) ;channel is the 0th element returned ConsoleWrite("Channel is " & $oElement.innerText & @CR) $oElement = _IETagNameAllGetCollection ($oChanName,6) ;station is the 6th element returned (rel 0) ConsoleWrite("Station is """ & $oElement.innerText & """" & @CR) ConsoleWrite(" ARTIST - TITLE" & @CR & _IEPropertyGet($oDiv, "innertext") & @CR) ;print the artist and title on the line below this _IEAction($oIE,"refresh") ;refresh the page _IELoadWait ($oIE) Sleep(5000) $temp = $temp + 1 WEnd _IEQuit ($oIE) ;closes browser session RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main","Display Inline Images","REG_SZ",$sIERegImg) ;reset IE image setting to original
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