Jump to content

AutoIT & IE7?


jbc1
 Share

Recommended Posts

In all of the ways I use it, it works just fine...

I think you'll want to post an example of what's failing for you. :)

Here is the (custom) function I use to wait for controls:

Func _MISC_ControlSearchWait($controlName, $windowName, $timeout, $logfile, $iFrameName = "" )
    $Previous_Time = TimerInit()
    While TimerDiff($Previous_Time) < $timeout
        $Win_hWnd = WinGetHandle($WindowName)
        If $Win_hWnd = "" Then
            _FileWriteLog($logfile, "WARNING:  _MISC_ControlSearchWait -> Unable to get handle to " & $WindowName & @CRLF)
        ;Return 0
        Else
        ;Once we have the handle to the window, we get a handle to the embedded Internet Explorer_Server control
            $wa = WinActivate($Win_hWnd)
            $cc = ControlClick ($Win_hWnd, "", "[Class:Internet Explorer_Server]")
        ;_FileWriteLog($logfile,"_MISC_ControlSearchWait -> " & $WindowName & "activated? $wa="& $wa & @CRLF)
        ;_FileWriteLog($logfile,"_MISC_ControlSearchWait -> Internet Explorer_Server clicked? $cc="& $cc & @CRLF)
            $hWnd_IEServer = ControlGetHandle($Win_hWnd,"","[Class:Internet Explorer_Server]")
            If $hWnd_IEServer = "" Then;  
                _FileWriteLog($logfile, "WARNING: _MISC_ControlSearchWait -> Error getting handle to the 'Internet Explorer_Server' control" & @CRLF)
            ;Return 0
            Else
            ;Once we have the handle to the embedded Internet Explorer_Server control, we try to get the object
                $o_IE = _MISC_ObjGetFromHWND($hWnd_IEServer)
                If Not IsObj($o_IE) Then;; An error occurred getting the Object from the window handle
                    _FileWriteLog($logfile, "WARNING: _MISC_ControlSearchWait -> Error getting the 'Internet Explorer_Server' object" & @CRLF)
                ;Return 0
                Else;we got the Internet Explorer_Server object from the handle...
                    If @NUMPARAMS = 4 Then; Look for the control in the current Internet Explorer object ($o_IE)
                    ; Then try to get the requested embedded object
                        $o_Control = _IEGetObjByName($o_IE, $ControlName)
                        If $o_Control <> 0 Then; we got the object
                            _FileWriteLog($logfile,"MESSAGE: _MISC_ControlSearchWait -> Control '" & $controlName & "' found in '" & $windowName & "' window." & @CRLF)
                            Return $o_Control
                        Else
                            _FileWriteLog($logfile, "WARNING: _MISC_ControlSearchWait -> Control '" & $controlName &"' not found in '" & $windowName & "' window." & @CRLF)
                        ;Return 0
                        Endif
                    ElseIf @NumParams = 5 Then; Look for the control inside the embedded iframe
                    ; get the iframe object
                        $o_iFrame = _IEFrameGetObjByName($o_IE, $iFrameName)
                        If $o_iFrame <> 0 Then; we got the iframe
                        ; try to get the control within the iframe
                            $o_Control = _IEGetObjByName($o_iFrame, $ControlName)
                            If $o_Control <> 0 Then; _IEGetObjByName got the object within the iFrame
                                _FileWriteLog($logfile,"MESSAGE: _MISC_ControlSearchWait -> Control '" & $controlName & "' found in '" & $iFrameName & "' iFrame." & @CRLF)
                                Return $o_Control
                            Else
                                _FileWriteLog($logfile, "WARNING: _MISC_ControlSearchWait -> Control '" & $controlName &"' not found in '" & $iFrameName & "' iFrame." & @CRLF)
                            ;Return 0
                            Endif
                        Else
                            _FileWriteLog($logfile, "WARNING: _MISC_ControlSearchWait -> iFrame '" & $iFrameName &"' not found in '" & $windowName & "' window." & @CRLF)
                        ;Return 0
                        Endif
                    EndIf
                EndIf
            EndIf
        EndIf
        _FileWriteLog($logfile,"MESSAGE: _MISC_ControlSearchWait -> Retrying in " & $G_MISC_CONTROLCHECK & " msecs..." & @CRLF)
        Sleep($G_MISC_CONTROLCHECK)
    WEnd
    _FileWriteLog($logfile,"ERROR!:  _MISC_ControlSearchWait -> " & $timeout &" msecs timeout reached!" & @CRLF)
    Return 0; Zero represents the control was not found within the specified timeout
EndFunc

Works just fine on IE6, but not on IE7.

Can anybody see any reason why?

Link to comment
Share on other sites

You'll need to narrow it down more.

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

Here is the (custom) function I use to wait for controls:

Func _MISC_ControlSearchWait($controlName, $windowName, $timeout, $logfile, $iFrameName = "" )
    $Previous_Time = TimerInit()
    While TimerDiff($Previous_Time) < $timeout
        $Win_hWnd = WinGetHandle($WindowName)
        If $Win_hWnd = "" Then
            _FileWriteLog($logfile, "WARNING:  _MISC_ControlSearchWait -> Unable to get handle to " & $WindowName & @CRLF)
    ;Return 0
        Else
    ;Once we have the handle to the window, we get a handle to the embedded Internet Explorer_Server control
            $wa = WinActivate($Win_hWnd)
            $cc = ControlClick ($Win_hWnd, "", "[Class:Internet Explorer_Server]")
    ;_FileWriteLog($logfile,"_MISC_ControlSearchWait -> " & $WindowName & "activated? $wa="& $wa & @CRLF)
    ;_FileWriteLog($logfile,"_MISC_ControlSearchWait -> Internet Explorer_Server clicked? $cc="& $cc & @CRLF)
            $hWnd_IEServer = ControlGetHandle($Win_hWnd,"","[Class:Internet Explorer_Server]")
            If $hWnd_IEServer = "" Then;  
                _FileWriteLog($logfile, "WARNING: _MISC_ControlSearchWait -> Error getting handle to the 'Internet Explorer_Server' control" & @CRLF)
        ;Return 0
            Else
        ;Once we have the handle to the embedded Internet Explorer_Server control, we try to get the object
                $o_IE = _MISC_ObjGetFromHWND($hWnd_IEServer)
                If Not IsObj($o_IE) Then;; An error occurred getting the Object from the window handle
                    _FileWriteLog($logfile, "WARNING: _MISC_ControlSearchWait -> Error getting the 'Internet Explorer_Server' object" & @CRLF)
            ;Return 0
                Else;we got the Internet Explorer_Server object from the handle...
                    If @NUMPARAMS = 4 Then; Look for the control in the current Internet Explorer object ($o_IE)
                ; Then try to get the requested embedded object
                        $o_Control = _IEGetObjByName($o_IE, $ControlName)
                        If $o_Control <> 0 Then; we got the object
                            _FileWriteLog($logfile,"MESSAGE: _MISC_ControlSearchWait -> Control '" & $controlName & "' found in '" & $windowName & "' window." & @CRLF)
                            Return $o_Control
                        Else
                            _FileWriteLog($logfile, "WARNING: _MISC_ControlSearchWait -> Control '" & $controlName &"' not found in '" & $windowName & "' window." & @CRLF)
                    ;Return 0
                        Endif
                    ElseIf @NumParams = 5 Then; Look for the control inside the embedded iframe
                ; get the iframe object
                        $o_iFrame = _IEFrameGetObjByName($o_IE, $iFrameName)
                        If $o_iFrame <> 0 Then; we got the iframe
                    ; try to get the control within the iframe
                            $o_Control = _IEGetObjByName($o_iFrame, $ControlName)
                            If $o_Control <> 0 Then; _IEGetObjByName got the object within the iFrame
                                _FileWriteLog($logfile,"MESSAGE: _MISC_ControlSearchWait -> Control '" & $controlName & "' found in '" & $iFrameName & "' iFrame." & @CRLF)
                                Return $o_Control
                            Else
                                _FileWriteLog($logfile, "WARNING: _MISC_ControlSearchWait -> Control '" & $controlName &"' not found in '" & $iFrameName & "' iFrame." & @CRLF)
                        ;Return 0
                            Endif
                        Else
                            _FileWriteLog($logfile, "WARNING: _MISC_ControlSearchWait -> iFrame '" & $iFrameName &"' not found in '" & $windowName & "' window." & @CRLF)
                    ;Return 0
                        Endif
                    EndIf
                EndIf
            EndIf
        EndIf
        _FileWriteLog($logfile,"MESSAGE: _MISC_ControlSearchWait -> Retrying in " & $G_MISC_CONTROLCHECK & " msecs..." & @CRLF)
        Sleep($G_MISC_CONTROLCHECK)
    WEnd
    _FileWriteLog($logfile,"ERROR!:  _MISC_ControlSearchWait -> " & $timeout &" msecs timeout reached!" & @CRLF)
    Return 0; Zero represents the control was not found within the specified timeout
EndFunc

Works just fine on IE6, but not on IE7.

Can anybody see any reason why?

...missing a lot of information here:

What happens when you run it? What was supposed to happen? What errors come up on the console pane when you run it from SciTE? What does it show in $logfile?

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...