Jump to content
Sign in to follow this  
Jonah

_IEAttach problem

Recommended Posts

Jonah

Hi,

I'm having some difficulty with IEAttach. I did search the forum for like posts, but didn't have any luck.

The problem here is that the _IEAttach call fails with an error code "3" for only one of the 5 platforms I run this on. For Windows 2k, XP SP2 (with IE6), XP SP3 (with IE7), Vista Home Premium, _IEAttach succeeds. For my Vista Ulimate machine, IEAttach returns 0 with @error = 3. That error code is not even listed in the IEAttach function description! Can anyone help me to figure out why only this instance is failing, and how I can fix the script operation?

Thanks!

\jonah

Case "LinkDistFileCheckMandatoryManual"
  ClickDownload()
  Local $page = GetCFGArgument("C:\rats\rats.cfg", "LinkDistPageURL")
  If $page == 0 Then
   WriteToLog("error", "Could not get parameter LinkDistPageURL from cfg file.")
   Return 0
   EndIf
  Sleep(5000)
  Local $oIE = _IEAttach($page, "URL")
  Local $linktext = GetCFGArgument("C:\rats\rats.cfg", "LinkDistLinkText")
  If $linktext == 0 Then
   WriteToLog("error", "Could not get parameter LinkDistLinkText from cfg file.")
   Return 0
   EndIf
  _IELinkClickByText($oIE, $linktext)
  WriteToLog("Functrace", "IEAttach returns " & $oIE & ", @error = " & @error)
  ;_IEAction( $oIE, "saveas")
   ; The DOM API for the saveas action will not return control to the script until the save box is gone. Try something else.
  IEClickSaveAs($oIE)
  Local $target = GetCFGArgument("C:\rats\rats.cfg", "FileCheckTarget")
  If $target == 0 Then
   WriteToLog("error", "Could not get parameter FileCheckTarget from cfg file.")
   Return 0
   EndIf
  Sleep(1000)
  _SaveAs("Save Web", $target)
  _IEQuit($oIE)
  WriteToLog("info", "RemediateLib::Remediate has succeeded with case " & $ReqtDescription)
  Return 1

Share this post


Link to post
Share on other sites
Valuater

This looks strange... I do not see the creation of the object

This looks like the return for the creation

Local $page = GetCFGArgument("C:\rats\rats.cfg", "LinkDistPageURL")

Local $oIE = _IEAttach($page, "URL")

But right after the attach() you use this function to create again?

Local $linktext = GetCFGArgument("C:\rats\rats.cfg", "LinkDistLinkText")

Not enough info to help!

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Jonah

Sorry, I added more code than was necessary - that is the next phase of the alogrithm, after the IE is attached, this is a separate routine to click a link. This link, the text of which is pulled via the GetCFG function, is fed to _IELinkClickByText($oIE, $linktext), but I do not assign the result of this function to the var $oIE, so the result of $oIE should still be the 0 from the _IEAttach() call. In other words, the link clicking is failing because of the IEAttach fail - I think. ^_^

Thanks!

Edited by Jonah

Share this post


Link to post
Share on other sites
Valuater

You are using a private UDF then asking _IEAttach() to attach to it, then that same private UDF is used to get the link, then you use _IE.. to click that link.

Again, due to the private UDF and the lack of ability to understand what is happening, I can not provide assistance.

... However, if this does work on the OS as stated above, I probably could not help anyways... Good Luck

8)

PS - Dale will show up sooner or later...

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
Jonah

The UDF simply opens a file, looks for a certain string, and returns a string. In this case, it returns the string "http://10.86.21.44/". This string is then input into

Local $oIE = _IEAttach($page, "URL")

, which is failing.

Is there a way to further debug?

Share this post


Link to post
Share on other sites
Valuater

The UDF simply opens a file, looks for a certain string, and returns a string. In this case, it returns the string "http://10.86.21.44/". This string is then input into

Local $oIE = _IEAttach($page, "URL")

, which is failing.

Is there a way to further debug?

Yes again the returned string "http://10.86.21.44/" is not an object!!

_IEAttach() is looking for an object as returned from IE Create()

see help

8)

EDIT/PS

I would use IECreate("http://10.86.21.44/") you can have as many $OIE objects as you want AFAIK

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
Jonah

I thought when using IEAttach in "URL" mode, it was looking for an instance of IE with the URL as listed in the first parameter?

Share this post


Link to post
Share on other sites
Valuater

I thought when using IEAttach in "URL" mode, it was looking for an instance of IE with the URL as listed in the first parameter?

String to search for (for "embedded" or "dialogbox", use Title sub-string or HWND of window)

Hmmm, I don't see it

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Jonah

; Parameter(s):     $s_string   - [b]String to search for[/b] (for "embedded" or "dialogbox", use Title sub-string or HWND of window)
;                   $s_mode     - Optional: specifies search mode
;                                   Title       = (Default) browser title
;                                   URL         = url of the current page
;                                   Text        = text from the body of the current page
;                                   HTML        = html from the body of the current page
;                                   HWND        = hwnd of the browser window
;                                   Embedded    = title sub-string or hwnd of the window embedding the control
;                                   DialogBox   = title sub-string or hwnd of modal/modeless dialogbox

"String to search for"...

doesn't that imply use a string? The "embedded" or "dialogbox" clause should not apply here, since I am not using those, so that leaves me with "String to search for", and "http://10.86.21.44/" is a string...

??

Share this post


Link to post
Share on other sites
Valuater

What you just said sounds correct, however I placed this isn my browser and got no where. "http://10.86.21.44/"

I help people by digging through the script, testing, testing and testing again... and then some more.

You are at a level of not providing enough info for me... can you create a small demonstration script?

Otherwise the technical man is Dale

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
DaleHohm

Can you simplify and summarize your situation?

For more debugging info, try SciTe debug mode and possibly _IEErrorHandlerRegister(). See if you can narrow down the failure scenario.

Dale

BTW, error 3 is $_IEStatus_InvalidDataType

Global Enum _; Error Status Types

$_IEStatus_Success = 0, _

$_IEStatus_GeneralError, _

$_IEStatus_ComError, _

$_IEStatus_InvalidDataType, _

$_IEStatus_InvalidObjectType, _

$_IEStatus_InvalidValue, _

$_IEStatus_LoadWaitTimeout, _

$_IEStatus_NoMatch, _

$_IEStatus_AccessIsDenied, _

$_IEStatus_ClientDisconnected


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

Share this post


Link to post
Share on other sites
Jonah

I can't even get this to fail on my XP laptop, have yet to try it on my Vista Ultimate machine...how could I use the debugging tools to investigate this further?

Here is a debugging script:

#include "IE.au3"

Debug()

Func Debug()
  Local $page = "http://www.jonahgregory.com/"
  
  Sleep(5000)
  Local $oIE = _IEAttach($page, "URL")
  
If $oIE == 0 Then
     MsgBox(0,"Result", "The _IEAttach result is: 0, couldn't find it...")
Else
    MsgBox(0,"Result", "The _IEAttach was successful, found the window.")
EndIf
  
  ;Local $linktext = GetCFGArgument("C:\rats\rats.cfg", "LinkDistLinkText")
  
  ;_IELinkClickByText($oIE, $linktext)
  ;WriteToLog("Functrace", "IEAttach returns " & $oIE & ", @error = " & @error)
  
  ;_IEAction( $oIE, "saveas")
   ; The DOM API for the saveas action will not return control to the script until the save box is gone. Try something else.

    #cs
  IEClickSaveAs($oIE)
  
  Local $target = GetCFGArgument("C:\rats\rats.cfg", "FileCheckTarget")
  If $target == 0 Then
   WriteToLog("error", "Could not get parameter FileCheckTarget from cfg file.")
   Return 0
   EndIf
  Sleep(1000)
  _SaveAs("Save Web", $target)
  _IEQuit($oIE)
  WriteToLog("info", "RemediateLib::Remediate has succeeded with case " & $ReqtDescription)
  Return 1
  #ce
EndFunc

Share this post


Link to post
Share on other sites
DaleHohm

Please run your script in SciTe is you are not already (valuable message written to console). IsObj($oIE) is the recommented test after _IECreate

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

Share this post


Link to post
Share on other sites
Juvigy

Try this one

$oIE = _IEAttach("Richelle's Easter pics are awesome...","Text")

Share this post


Link to post
Share on other sites
Valuater

I can't even get this to fail on my XP laptop, have yet to try it on my Vista Ultimate machine...how could I use the debugging tools to investigate this further?

Here is a debugging script:

#include "IE.au3"

Debug()

Func Debug()
  Local $page = "http://www.jonahgregory.com/"
  
  Sleep(5000)
  Local $oIE = _IEAttach($page, "URL")
  
If $oIE == 0 Then
     MsgBox(0,"Result", "The _IEAttach result is: 0, couldn't find it...")
Else
    MsgBox(0,"Result", "The _IEAttach was successful, found the window.")
EndIf
  
  ;Local $linktext = GetCFGArgument("C:\rats\rats.cfg", "LinkDistLinkText")
  
  ;_IELinkClickByText($oIE, $linktext)
  ;WriteToLog("Functrace", "IEAttach returns " & $oIE & ", @error = " & @error)
  
  ;_IEAction( $oIE, "saveas")
   ; The DOM API for the saveas action will not return control to the script until the save box is gone. Try something else.

    #cs
  IEClickSaveAs($oIE)
  
  Local $target = GetCFGArgument("C:\rats\rats.cfg", "FileCheckTarget")
  If $target == 0 Then
   WriteToLog("error", "Could not get parameter FileCheckTarget from cfg file.")
   Return 0
   EndIf
  Sleep(1000)
  _SaveAs("Save Web", $target)
  _IEQuit($oIE)
  WriteToLog("info", "RemediateLib::Remediate has succeeded with case " & $ReqtDescription)
  Return 1
  #ce
EndFunc
This fails on my Win Xp sp3

3.3.0.0 Autoit

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Jonah

This fails on my Win Xp sp3

3.3.0.0 Autoit

8)

Did you have an IE up and running with that URL loaded? This does work on my XP setup.

So if I use IsObj() after my test fails (on my other platform which does not work, of course....) what will that tell me? Does it do more than just tell me it passed or failed?

Thanks,

sorry for the trouble ...

Share this post


Link to post
Share on other sites
Valuater

Did you have an IE up and running with that URL loaded? This does work on my XP setup.

Yes, after opening the URL in IE7 it worked fine!

************************************************************

IsObj will only tell you if it passed or failed

.......... from help

IsObj

--------------------------------------------------------------------------------

Checks if a variable or expression is an object type.

IsObj ( variable )

Parameters

variable The variable/expression to check.

Return Value

Success: Returns 1 if expression is an object variable.

Failure: Returns 0 if expression is not an object variable.

*******************************************************

_IEErrorHandlerRegister()

Will give a lot of info

************************************

OK, I looked up IsObj for you in the help file, you can start using the help file to see all the info for the error handler function above.

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
DaleHohm

I also recommended this:

> Please run your script in SciTe is you are not already (valuable message written to console).

If you are not running from SciTe and you have not tried SciTe debug mode you are missing the boat for debugging.

Dale

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

Share this post


Link to post
Share on other sites
pdaughe

Dale,

I just installed IE8 on a Vista Home Premium machine. IEAttach now fails (no match). The subject application worked fine under Vista with IE7.

Here's what I have observed:

1. A COM error occurs in __IEControlGetObjFromHWND when this statement is executed:

$pObj = $oIE.document.parentwindow

I did verify that $oIE (the return value from $aRet[4].Script) is a valid object.

2. In the _IEAttach function, when a window handle is passed as the first argument, it may be wise to check the result from:

ControlGetHandle($s_string, "", "[CLASS:Internet Explorer_Server; INSTANCE:" & $i_instance & "]")

This was the first check I put in and _IEAttach IS successfully finding the IE server control.

3. In the __IEControlGetObjFromHWND function, it may also be beneficial to check @error after:

__IESendMessageTimeout($hWin, $WM_HTML_GETOBJECT, 0, 0, $SMTO_ABORTIFHUNG, 1000, $lResult)

I also put this check in and @error is zero, which in turn got me down to checking $oIE to ensure a valid object is returned from the Script method (which it is), and finally to checking the result of $oIE.document.parentwindow, where indeed the COM error occurs.

I reviewed all the posts on _IEAttach and see that there can be challenges here. In my case, the culprit is DEFINITELY IE8 (I boot from my backup (containing IE7) and the application runs fine).

I don't know if any of this is useful -- I'm simply trying to contribute ^_^

Sincerely,

Paul

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.