Jump to content
Sign in to follow this  
logcomptechs

Question about Firefox and Autoit

Recommended Posts

logcomptechs

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.

Share this post


Link to post
Share on other sites
jerem488

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]

Share this post


Link to post
Share on other sites
logcomptechs

Place this code in the IE au3 file or in my script.

Share this post


Link to post
Share on other sites
FireFox

Place this code in the IE au3 file or in my script.

:) ?? Do it yourself, we dont like lazzy people, make a little effort and if youve again a problem then post your script ...

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
logcomptechs

:) ?? Do it yourself, we dont like lazzy people, make a little effort and if youve again a problem then post your script ...

Cheers, FireFox.

Was not asking for him to do it, sorry if sounded that way, I was just asking where do I put it, I am far from lazy.

Share this post


Link to post
Share on other sites
Melba23

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

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites
logcomptechs

Yep, already on it, and thank you both.

Share this post


Link to post
Share on other sites
Mars

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.

Share this post


Link to post
Share on other sites
James

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.

Share this post


Link to post
Share on other sites
Mars

Bit of a long way to do it if you ask me.

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

Share this post


Link to post
Share on other sites
logcomptechs

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

Share this post


Link to post
Share on other sites
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

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  

×