Jump to content

COM problems again


Recommended Posts

This makes no sense to me. I am getting all kinds of errors that don't seem to have any bearing to what I am doing:

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler 
Func MyErrFunc() 
   $HexNumber=hex($oMyError.number,8) 
   Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _
               "Number is: " & $HexNumber & @CRLF & _
               "Windescription is: " & $oMyError.windescription ) 

   SetError(1); something to check for when this function returns 
Endfunc

$ie = ObjCreate("InternetExplorer.Application")
$ie.visible = true
$ie.Navigate2("http://windowsupdate.microsoft.com")
While $ie.ReadyState <> 4
    Sleep(250)
WEnd
Sleep(5000)
msgbox(0,"",$ie.frames.length);gives variable must be of type "object"
;msgbox(0,"",$ie.frames.item(0).document.documentElement.innerHTML) ;This one gives some kind of object used outside of a "with" statement or something
;parent.fnScan()

Can someone tell me what I am doing wrong?

Who else would I be?
Link to comment
Share on other sites

I think your trouble is that frames are children of the document object rather than the application object. Try:

msgbox(0,"",$ie.document.frames.length)

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

Thank you so much dale, I forget that in javascript, anything directly mentioned in the document object or the window does not need to be pre-mentioned.

Another question is how to call a script function in the page. fnScan is a function created in the main html of the page, but I cannot seem to access it with $ie.fnScan() or $ie.document.fnScan(). I can call $ie.document.frames.item("eContent").parent.fnScan() which doesn't error out, but doesn't function either.

Edited by this-is-me
Who else would I be?
Link to comment
Share on other sites

Here's another kafuffle, there seems to be a problem with com return values in if statements being assigned instead of compared. See following:

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler 
Func MyErrFunc() 
   $HexNumber=hex($oMyError.number,8) 
   Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _
               "Number is: " & $HexNumber & @CRLF & _
               "Windescription is: " & $oMyError.windescription ) 

   SetError(1); something to check for when this function returns 
Endfunc

$ie = ObjCreate("InternetExplorer.Application")
$ie.visible = true
$ie.Navigate2("http://windowsupdate.microsoft.com")
While $ie.ReadyState <> 4
    Sleep(250)
WEnd
Sleep(10000)
;MsgBox(0, "", $ie.document.frames("eContent").document.all(0).tagName)
for $i = 0 to $ie.document.frames("eContent").document.all.length
    if $ie.document.frames("eContent").document.all($i).getAttribute("href")="javascript:parent.fnScan();" Then
        MsgBox(0,"", $ie.document.frames("eContent").document.all($i).tagName)
    ;$ie.document.frames("eContent").document.all($i).click()
        ExitLoop
    EndIf
Next
;msgbox(0,"",$ie.frames.item(0).document.documentElement.innerHTML)
;parent.fnScan()

With the above, each and every element in the page has the href assigned to it instead of being compared to it. I think this is one Sven may need to look into as a bug. I will make a duplicate post in the bug reports to bring it up as a current issue.

Edited by this-is-me
Who else would I be?
Link to comment
Share on other sites

It appears that AutoIt allows '=' to be used as both an assignment and comparison operator and must make decisions on what to do based on context.

Perhaps you could try '==' as an alternative to see if it makes the correct choice.

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

Thank you so much dale, I forget that in javascript, anything directly mentioned in the document object or the window does not need to be pre-mentioned.

Another question is how to call a script function in the page. fnScan is a function created in the main html of the page, but I cannot seem to access it with $ie.fnScan() or $ie.document.fnScan(). I can call $ie.document.frames.item("eContent").parent.fnScan() which doesn't error out, but doesn't function either.

<{POST_SNAPBACK}>

There is a method of the window object called execScript("expression", "lang")

I expected $ie.document.parentwindow.execScript("fnScan();","Javascript") to work but it doesn't. Must have the hierarchy hosed there somewhere. It may be worth playing with however.

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