Sign in to follow this  
Followers 0
tbui

_IELoadWait modifies passed object?

10 posts in this topic

I am running into a weird issue with _IELoadWait. From my test (below), it seems as if _IELoadWait modifies the $IEHandler passed to it.

When I ran the code, I got two message boxes with values:

First One: "0, 6" (this is correct, timed out)

Second One: "0, 4" (this means that $IEHandler was of invalid type...)

I cannot figure out why $IEHandler was changed. If anyone has any ideas, let's discuss.

I am running the latest version of AutoIT on Windows Server 2008 (32b) and using a non-admin account (I don't think this matters).

#include <IE.au3>

Dim $IEHandler 
Dim $ReturnCode

$IEHandler = _IECreate("http://my.unm.edu/", 0, 1, 0, 1)

$ReturnCode = _IELoadWait($IEHandler, 0, 1000)
MsgBox(0, "DEBUG", $ReturnCode & " " & @Error)
$ReturnCode = _IELoadWait($IEHandler, 0, 1000)
MsgBox(0, "DEBUG", $ReturnCode & " " & @Error)

Share this post


Link to post
Share on other sites



There is nothing in _IELoadWait that modifies the IE object variable - it is real-only.

If this is what you are getting, something else is going on. See if this is reproducible after a reboot.

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

#4 ·  Posted (edited)

I can confirm that type of problem.

This week it occured at my work on one computer of our customer where up to now ran my script for imports of data from web portal into firm's database into information system.

It occurs only on computer with IE8 and I think it started after some automatized Windows or IE update.

I made some testing scripts and I think I identified source of problem.

It seems that it can be related to security of new IE and zones.

I had to add URL address of that web portal to trusted zone to make my import working also from scheduler without looged user.

And as I read here on the forum new versions of IE create new instance when it goes to different type of security zone.

My testing scripts seems to prove that theory because it changes/corrupts $oIE object after _IENavigate() or _IECreate() if URL is in different security zone so the following _IELoadWait() returns invalid object type or similar errors.

I tried workaround by using _IECreate with about:blank which should be OK in all cases then remember IE hWnd by _IEPropertyGet

then call _IENavigate() without LoadWait parameter and after that restore corrupted $oIE object by _IEAttach with remembered hWnd.

Now following _IELoadWait don't end with error but it seems that it doesn't wait for IE to be finished with loading.

I worked on this issue yesterday at work and now I have no access to my scripts so I will post them here on Monday.

Edited by Zedna

Share this post


Link to post
Share on other sites

There is nothing in _IELoadWait that modifies the IE object variable - it is real-only.

If this is what you are getting, something else is going on. See if this is reproducible after a reboot.

Dale

Source of problems is _IENavigate(). It's internally called also inside _IECreate().

See my previous post for details.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

At our customer we run my problematic import script on other machine temporary as workaround without any problems.

On that machine there is IE version 7.0

Problems are only on machine with IE 8.0

Is it possible to downgrade IE from 8.0 to 7.0? That maybe could help if possible.

Edited by Zedna

Share this post


Link to post
Share on other sites

What IE version do you have?

I am using IE8. After studying your comments, I am going to downgrade to IE7 and test my test again.

@JohnOne: I would like to try IE9, but my organization would throw a fuss if they find out that I am using beta for production.

Thank you everyone for your confirmation and analysis. I will post here again if I find anything else. And please update as well if you find a workaround for IE8.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Sorry for delay, yeasterday I was very busy.

So here is my testing script with workaroung using

_IEPropertyGet ($oIE, "hwnd")

$oIE = _IEAttach($ie_hwnd, 'HWND')

Note: As URL you should use some URL which is in different security zone of your IE.

1) simplified version without so many error checking and helper messageboxes so it's better readable

#Include <IE.au3>

$url = "https://secure.lkw-walter.com/partner/Login.aspx?lng=EN"
$url2 = "https://secure.lkw-walter.com/"

$objErr = ObjEvent("AutoIt.Error","MyErrFunc")

$error_com = ''
$oIE = _IECreate("about:blank", 0, 1, 0) ; Visible=true LoadWait=false
_IELoadWait($oIE, 150)

$ie_hwnd = _IEPropertyGet ($oIE, "hwnd") ; remember IE hWnd
_IENavigate($oIE, $url, 0) ; LoadWait=false
$oIE = _IEAttach($ie_hwnd, 'HWND') ; restore $oIE object corrupted  by calling _IENavigate
;~$oIE = _IEAttach($url, 'URL')
_IELoadWait($oIE, 150)

;~$oIE.document.execCommand("Refresh") ; because navigate is not finished but LoadWait immediatelly after Attach doesn't wait
;~ $oIE.Stop()
;~ _IENavigate($oIE, $url, 0)
;~ $oIE = _IEAttach($ie_hwnd, 'HWND')
;~ _IELoadWait($oIE, 150)
;~ _IENavigate($oIE, $url2, 0)
;~ $oIE = _IEAttach($ie_hwnd, 'HWND')
;~ _IELoadWait($oIE, 150)

MsgBox(0, 'OK', 'FINISH')

Func MyErrFunc()
    MsgBox(16, "Error", "COM Error!" & @CRLF & @CRLF & _
            "Description: " & @TAB & $objErr.description & @CRLF & _
            "Win. description:" & @TAB & $objErr.windescription & @CRLF & _
            "Line number: " & @TAB & $objErr.scriptline & @CRLF & _
            "Error number: " & @TAB & Hex($objErr.number, 8) & @CRLF & _
            "Object: " & @TAB & $objErr.source)

    $error_com = $objErr.description
    SetError(1)
EndFunc

2) full version with all error checking and helper messageboxes

#Include <IE.au3>

$url = "https://secure.lkw-walter.com/partner/Login.aspx?lng=EN"
$url2 = "https://secure.lkw-walter.com/"

$objErr = ObjEvent("AutoIt.Error","MyErrFunc")

$error_com = ''
$oIE = _IECreate("about:blank", 0, 1, 0) ; Visible=true LoadWait=false
If @error Then MsgBox(0,'','Error _IECreate! ' & @error)
_IELoadWait($oIE, 150)
If @error Then MsgBox(0,'','Error LoadWait1 ' & @error)
If $error_com <> '' Then 
 MsgBox(16, 'Error', 'Error creating IE!' & @CRLF & $error_com)
Else
 MsgBox(64, 'OK', 'IE created successfully.')
EndIf

If Not IsObj($oIE) Then
 MsgBox(16, 'Error', 'Error creating IE - Not IsObj!' & @CRLF & $error_com)
 Exit
EndIf

; remember IE hWnd
$ie_hwnd = _IEPropertyGet ($oIE, "hwnd")

;~ MsgBox(0,'','Before navigate')
_IENavigate($oIE, $url, 0) ; LoadWait=false
If @error Then MsgBox(0,'','Error navigate 1! ' & @error)
;~     MsgBox(0,'','After navigate')
$oIE = _IEAttach($ie_hwnd, 'HWND') ; restore $oIE object corrupted  by calling _IENavigate
;~$oIE = _IEAttach($url, 'URL')
If @error Then MsgBox(0,'','Error Attach ' & @error)
;~$oIE = _IEAttach($url, 'URL')
;~If @error Then MsgBox(0,'','Error Attach2 ' & @error)
_IELoadWait($oIE, 150)
If @error Then MsgBox(0,'','Error LoadWait2 ' & @error)

;~$oIE.document.execCommand("Refresh") ; because navigate is not finished but LoadWait immediatelly after Attach doesn't wait
;~ $oIE.Stop()
;~ _IENavigate($oIE, $url, 0)
;~ If @error Then MsgBox(0,'','Error navigate 2! ' & @error)
;~ $oIE = _IEAttach($ie_hwnd, 'HWND')
;~ _IELoadWait($oIE, 150)
;~ If @error Then MsgBox(0,'','Error LoadWait3  ' & @error)
;~ MsgBox(0, 'OK', 'OK')
;~ _IENavigate($oIE, $url2, 0)
;~ $oIE = _IEAttach($ie_hwnd, 'HWND')
;~ _IELoadWait($oIE, 150)

MsgBox(0, 'OK', 'FINISH')

Func MyErrFunc()
    MsgBox(16, "Error", "COM Error!" & @CRLF & @CRLF & _
            "Description: " & @TAB & $objErr.description & @CRLF & _
            "Win. description:" & @TAB & $objErr.windescription & @CRLF & _
            "Line number: " & @TAB & $objErr.scriptline & @CRLF & _
            "Error number: " & @TAB & Hex($objErr.number, 8) & @CRLF & _
            "Object: " & @TAB & $objErr.source)

    $error_com = $objErr.description
    SetError(1)
EndFunc

EDIT:

here is original script, before workaround:

#Include <IE.au3>

$url = "https://secure.lkw-walter.com/partner/Login.aspx?lng=EN"

$oIE = _IECreate($url, 0, 1, 0) ; Visible=true LoadWait=false
If @error Then MsgBox(0,'','Error _IECreate! ' & @error)
_IELoadWait($oIE, 150)
If @error Then MsgBox(0,'','Error LoadWait ' & @error)
MsgBox(64, 'OK', 'IE created successfully.')
Edited by Zedna

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  
Followers 0