Jump to content

The difference of execution of _IELoadWait from compilated exe and from scite


Recommended Posts

Dear friends!

Please tell me why my script running perfectly, when I start it from scite (by pressing F5), but when I compile it to exe - the _IELoadWait is not working - no pause before IE will load page:

$oIE =  _IECreate ( $Addr, 0, 1, 0 ) 
_IELoadWait ( $oIE ) 
 
$oIECtrl =  _IEGetObjById ( $oIE, "pre_pwd" ) 
_IEFormElementSetValue ( $oIECtrl, $CurPass, 0 ) 
 
Local  $oIECtrl =  _IEGetObjById ( $oIE, "submit_but" )
_IEAction ( $oIECtrl, "click" ) 

 

The same operator (_IELoadWait) is working perfectly on the same machine in different script (and different site).

My system is Win8.1Prof x64, Autoit 3.3.12.0, IE 11

Link to comment
Share on other sites

  • Developers

This can't be the whole script that has the issue. 

Is SciTE started with Admin rights?
Are you compiling as X86 or X64?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I am very sorry - I forgot to write full text of script:

If $OpenNew Then

        $oIE = _IECreate( $Addr, 0, 1, 0 )

    Else

        $oIE.Navigate2( $Addr, 2048 )

        Sleep( 1.5 * 1000 ) ; 1 sec
        $oIE    =_IEAttach( WinGetHandle("") ,"embedded" )

    EndIf
    
    _IELoadWait( $oIE )
    
    $oIECtrl = _IEGetObjById( $oIE, "pre_pwd" )
    _IEFormElementSetValue( $oIECtrl, $CurPass, 0 )

    Local $oIECtrl = _IEGetObjById( $oIE, "submit_but" ) ; получим кнопку "Авторизация" и нажмем её
    _IEAction( $oIECtrl, "click" )

 And this code is runnig twice - at first it working with $OpenNew = True, second time - $OpenNew = False (to open 2 different tabs in IE)

Also I found error in SciTE output panel:

IE.au3 T3.0-1 Warning from function _IEAttach, $_IESTATUS_NoMatch

 

But script is working as planned, when started from scite.

Link to comment
Share on other sites

ildary,

The problem is that the function _IEAttach is failing, so $oIE is not an object. See if this is what you want:

#include <IE.au3>

For $iOpenNew = 0 To 1
    If $iOpenNew = 0 Then
        Local $oIE1 = _IECreate("www.google.com", 0, 1, 0)
    Else
        Local $oIE2 = _IENavigate2($oIE1, "www.google.com", 1, 2048)
        MsgBox(0,0,"Check if there is another google tab.")
        _IENavigate2($oIE2, "www.autoitscript.com")
    EndIf
Next
MsgBox(0,0,"Done!")
Exit

Func _IENavigate2(ByRef $oObject, $sUrl, $iWait = 1, $BrowserNavFlag = 0)

    #cs
        $BrowserNavFlags: Default is 0, navigate in the same window.

        navOpenInNewWindow = 1
        navNoHistory = 2
        navNoReadFromCache = 4
        navNoWriteToCache = 8
        navAllowAutosearch = 16
        navBrowserBar = 32
        navHyperlink = 64
        navEnforceRestricted = 128
        navNewWindowsManaged = 256
        navUntrustedForDownload = 512
        navTrustedForActiveX = 1024
        navOpenInNewTab = 2048
        navOpenInBackgroundTab = 4096
        navKeepWordWheelText = 8192
        navVirtualTab = 16384
        navBlockRedirectsXDomain = 32768
        navOpenNewForegroundTab = 65536
    #ce

    If Not __IEIsObjType($oObject, "documentContainer") Then
        If @error = $_IESTATUS_InvalidDataType Then
            __IEConsoleWriteError("Error", "_IENavigate", "$_IESTATUS_InvalidDataType")
            Return SetError($_IESTATUS_InvalidDataType, 1, 0)
        Else
            __IEConsoleWriteError("Error", "_IENavigate", "$_IESTATUS_InvalidObjectType")
            Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
        EndIf
    EndIf
    ;
    If $BrowserNavFlag Then
        Local $iRandom = Random(10001, 99999, 1), $oIE, $iNotifyStatus, $hTimer = TimerInit()

        $oObject.Navigate2("about:blank-" & $iRandom, $BrowserNavFlag)
        If @error Then ; Trap COM error, report and return
            __IEConsoleWriteError("Error", "_IENavigate", "$_IESTATUS_COMError", @error)
            Return SetError($_IESTATUS_ComError, @error, 0)
        EndIf

        $iNotifyStatus = _IEErrorNotify()
        _IEErrorNotify(False)

        While Not IsObj($oIE)
            Sleep(500)
            $oIE = _IEAttach("about:blank-" & $iRandom, "URL")
            If TimerDiff($hTimer) > 30000 Then
                _IEErrorNotify($iNotifyStatus)
                __IEConsoleWriteError("Error", "_IENavigate", "", "Time out. TimerDiff > 30000ms")
                Return SetError(1, 0, 0)
            EndIf
        WEnd

        _IEErrorNotify($iNotifyStatus)

        $oIE.Navigate2($sUrl)
        If @error Then ; Trap COM error, report and return
            __IEConsoleWriteError("Error", "_IENavigate", "$_IESTATUS_COMError", @error)
            Return SetError($_IESTATUS_ComError, @error, 0)
        EndIf

        If $iWait Then
            _IELoadWait($oIE)
            Return SetError(@error, 0, $oIE)
        EndIf

        Return SetError($_IESTATUS_Success, 0, $oIE)
    EndIf
    ;
    $oObject.Navigate2($sUrl)
    If @error Then ; Trap COM error, report and return
        __IEConsoleWriteError("Error", "_IENavigate", "$_IESTATUS_COMError", @error)
        Return SetError($_IESTATUS_ComError, @error, 0)
    EndIf
    ;
    If $iWait Then
        _IELoadWait($oObject)
        Return SetError(@error, 0, -1)
    EndIf

    Return SetError($_IESTATUS_Success, 0, -1)
EndFunc   ;==>_IENavigate

 

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