Jump to content

Question about Firefox and Autoit


Recommended Posts

The functions for Internet Explorer are nice, waiting until the page loads, then going onto the next line of code. But I hate using Internet Explorer (Horrible Search Function, among the rest of the downfalls of using Internet Explorer). So I was wondering if their was any ways I could see if a page has fully loaded in Firefox, so it knows to move on to the next line of code. If any has any kind of solution, that would be great, and thank you.

Link to comment
Share on other sites

You can resume the autoit file and change in terms of firefox !

Func _IELoadWait(ByRef $o_object, $i_delay = 0, $i_timeout = -1)
    If Not IsObj($o_object) Then
        __IEErrorNotify("Error", "_IELoadWait", "$_IEStatus_InvalidDataType")
        SetError($_IEStatus_InvalidDataType, 1)
        Return 0
    EndIf
    
    If Not __IEIsObjType($o_object, "browserdom") Then
        __IEErrorNotify("Error", "_IELoadWait", "$_IEStatus_InvalidObjectType", ObjName($o_object))
        SetError($_IEStatus_InvalidObjectType, 1)
        Return 0
    EndIf
    
    Local $oTemp, $f_Abort = False, $i_ErrorStatusCode = $_IEStatus_Success
    
    ; Setup internal error handler to Trap COM errors, turn off error notification
    Local $status = __IEInternalErrorHandlerRegister()
    If Not $status Then __IEErrorNotify("Warning", "_IELoadWait", _
            "Cannot register internal error handler, cannot trap COM errors", _
            "Use _IEErrorHandlerRegister() to register a user error handler")
    Local $f_NotifyStatus = _IEErrorNotify() ; save current error notify status
    _IEErrorNotify(False)
    
    Sleep($i_delay)
    ;
    Local $IELoadWaitTimer = TimerInit()
    If $i_timeout = -1 Then $i_timeout = $__IELoadWaitTimeout
    
    Switch ObjName($o_object)
        Case "IWebBrowser2"; InternetExplorer
            While Not (String($o_object.readyState) = "complete" Or $o_object.readyState = 4 Or $f_Abort)
                ; Trap unrecoverable COM errors
                If (TimerDiff($IELoadWaitTimer) > $i_timeout) Then
                    $i_ErrorStatusCode = $_IEStatus_LoadWaitTimeout
                    $f_Abort = True
                EndIf
                If @error = $_IEStatus_ComError And __IEComErrorUnrecoverable() Then
                    $i_ErrorStatusCode = __IEComErrorUnrecoverable()
                    $f_Abort = True
                EndIf
                Sleep(100)
            WEnd
            While Not (String($o_object.document.readyState) = "complete" Or $o_object.document.readyState = 4 Or $f_Abort)
                If (TimerDiff($IELoadWaitTimer) > $i_timeout) Then
                    $i_ErrorStatusCode = $_IEStatus_LoadWaitTimeout
                    $f_Abort = True
                EndIf
                ; Trap unrecoverable COM errors
                If @error = $_IEStatus_ComError And __IEComErrorUnrecoverable() Then
                    $i_ErrorStatusCode = __IEComErrorUnrecoverable()
                    $f_Abort = True
                EndIf
                Sleep(100)
            WEnd
        Case "DispHTMLWindow2" ; Window, Frame, iFrame
            While Not (String($o_object.document.readyState) = "complete" Or $o_object.document.readyState = 4 Or $f_Abort)
                If (TimerDiff($IELoadWaitTimer) > $i_timeout) Then
                    $i_ErrorStatusCode = $_IEStatus_LoadWaitTimeout
                    $f_Abort = True
                EndIf
                ; Trap unrecoverable COM errors
                If @error = $_IEStatus_ComError And __IEComErrorUnrecoverable() Then
                    $i_ErrorStatusCode = __IEComErrorUnrecoverable()
                    $f_Abort = True
                EndIf
                Sleep(100)
            WEnd
            While Not (String($o_object.top.document.readyState) = "complete" Or $o_object.top.document.readyState = 4 Or $f_Abort)
                If (TimerDiff($IELoadWaitTimer) > $i_timeout) Then
                    $i_ErrorStatusCode = $_IEStatus_LoadWaitTimeout
                    $f_Abort = True
                EndIf
                ; Trap unrecoverable COM errors
                If @error = $_IEStatus_ComError And __IEComErrorUnrecoverable() Then
                    $i_ErrorStatusCode = __IEComErrorUnrecoverable()
                    $f_Abort = True
                EndIf
                Sleep(100)
            WEnd
        Case "DispHTMLDocument" ; Document
            $oTemp = $o_object.parentWindow
            While Not (String($oTemp.document.readyState) = "complete" Or $oTemp.document.readyState = 4 Or $f_Abort)
                If (TimerDiff($IELoadWaitTimer) > $i_timeout) Then
                    $i_ErrorStatusCode = $_IEStatus_LoadWaitTimeout
                    $f_Abort = True
                EndIf
                ; Trap unrecoverable COM errors
                If @error = $_IEStatus_ComError And __IEComErrorUnrecoverable() Then
                    $i_ErrorStatusCode = __IEComErrorUnrecoverable()
                    $f_Abort = True
                EndIf
                Sleep(100)
            WEnd
            While Not (String($oTemp.top.document.readyState) = "complete" Or $oTemp.top.document.readyState = 4 Or $f_Abort)
                If (TimerDiff($IELoadWaitTimer) > $i_timeout) Then
                    $i_ErrorStatusCode = $_IEStatus_LoadWaitTimeout
                    $f_Abort = True
                EndIf
                ; Trap unrecoverable COM errors
                If @error = $_IEStatus_ComError And __IEComErrorUnrecoverable() Then
                    $i_ErrorStatusCode = __IEComErrorUnrecoverable()
                    $f_Abort = True
                EndIf
                Sleep(100)
            WEnd
        Case Else ; this should work with any other DOM object
            $oTemp = $o_object.document.parentWindow
            While Not (String($oTemp.document.readyState) = "complete" Or $oTemp.document.readyState = 4 Or $f_Abort)
                If (TimerDiff($IELoadWaitTimer) > $i_timeout) Then
                    $i_ErrorStatusCode = $_IEStatus_LoadWaitTimeout
                    $f_Abort = True
                EndIf
                ; Trap unrecoverable COM errors
                If @error = $_IEStatus_ComError And __IEComErrorUnrecoverable() Then
                    $i_ErrorStatusCode = __IEComErrorUnrecoverable()
                    $f_Abort = True
                EndIf
                Sleep(100)
            WEnd
            While Not (String($oTemp.top.document.readyState) = "complete" Or $o_object.top.document.readyState = 4 Or $f_Abort)
                If (TimerDiff($IELoadWaitTimer) > $i_timeout) Then
                    $i_ErrorStatusCode = $_IEStatus_LoadWaitTimeout
                    $f_Abort = True
                EndIf
                ; Trap unrecoverable COM errors
                If @error = $_IEStatus_ComError And __IEComErrorUnrecoverable() Then
                    $i_ErrorStatusCode = __IEComErrorUnrecoverable()
                    $f_Abort = True
                EndIf
                Sleep(100)
            WEnd
    EndSwitch
    
    ; restore error notify and error handler status
    _IEErrorNotify($f_NotifyStatus) ; restore notification status
    __IEInternalErrorHandlerDeRegister()
    
    Switch $i_ErrorStatusCode
        Case $_IEStatus_Success
            SetError($_IEStatus_Success)
            Return 1
        Case $_IEStatus_LoadWaitTimeout
            __IEErrorNotify("Warning", "_IELoadWait", "$_IEStatus_LoadWaitTimeout")
            SetError($_IEStatus_LoadWaitTimeout, 3)
            Return 0
        Case $_IEStatus_AccessIsDenied
            __IEErrorNotify("Warning", "_IELoadWait", "$_IEStatus_AccessIsDenied", _
                    "Cannot verify readyState.  Likely casue: cross-site scripting security restriction.")
            SetError($_IEStatus_AccessIsDenied)
            Return 0
        Case $_IEStatus_ClientDisconnected
            __IEErrorNotify("Error", "_IELoadWait", "$_IEStatus_ClientDisconnected", _
                    "Browser has been deleted prior to operation.")
            SetError($_IEStatus_ClientDisconnected)
            Return 0
        Case Else
            __IEErrorNotify("Error", "_IELoadWait", "$_IEStatus_GeneralError", "Invalid Error Status - Notify IE.au3 developer")
            SetError($_IEStatus_GeneralError)
            Return 0
    EndSwitch
EndFunc   ;==>_IELoadWait

I have only put the function of _IELoadWait, but this function use others function of this file.

Good luck

Qui ose gagneWho Dares Win[left]CyberExploit[/left]

Link to comment
Share on other sites

  • Moderators

logcomptechs,

Download the FF.au3 file from the link AdmiralAlkex provided. Put it in your script using an #Include directive. Then use the _FFLoadWait() function in your script.

M23

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

What I do for my scripts, although it might not be the most efficient is do a pixelgetcolor for the little box that appears when the page is loading. When the page is done loading the box disappears so it just loops in the pixelgetcolor until it is the right color.

Link to comment
Share on other sites

What I do for my scripts, although it might not be the most efficient is do a pixelgetcolor for the little box that appears when the page is loading. When the page is done loading the box disappears so it just loops in the pixelgetcolor until it is the right color.

Bit of a long way to do it if you ask me.
Link to comment
Share on other sites

Maybe, but it is a lot shorter the the script posted :)

I might just try that, cause the FF.au3 is all messed up, things do not work right on it, not sure it is because i have version 3.0 or what, but it just does not work right. That's a good idea and it will take me a few minutes to program that, instead of trying to fix the FF.au3

Link to comment
Share on other sites

  • 2 weeks later...
Guest KeeForm

Hi logcomptechs,

were your problems regarding FF.au3 solved? What solution did you try in the end? Thanks, Dave

I might just try that, cause the FF.au3 is all messed up, things do not work right on it, not sure it is because i have version 3.0 or what, but it just does not work right. That's a good idea and it will take me a few minutes to program that, instead of trying to fix the FF.au3

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