Sign in to follow this  
Followers 0
Matrix112

UDF FfLoad

7 posts in this topic

#1 ·  Posted (edited)

Hi,

this UDF pauses the script until Firefox finished loading.

Use the window info tool to get coordinates of the left side of the loading bar.

This is my first UDF :mad2:

I think that can be useful. ;)

FfLoad.au3

;======================================================================================
;
; Function Name:   _FfLoadWait()
; Description:      Pauses the script until Firefox finished loading.
; Parameter(s):  $x  - The X coordinate of the Blue loading bar.
;                         $y  - The Y coordinate of the Blue loading bar.
;                         $pcm  - PixelCoordMode
;                         0 = relative coords to the active window
;                         1 = absolute screen coordinates (default)
;                         2 = relative coords to the client area of the active window
;              $lbc  - Dec clour of the loading bar (optional) Default is standard 
;                        bar colour.
; Requirement(s):   Include FfLoad.au3
; Return Value(s):  Nothing. 
; Author(s):           Christoph Krogmann <ch.krogmann@gmx.de>
; Note(s):            During search for the coordinate, choose a point at the left
;                          side of the loading bar!
;
;======================================================================================
;
Func _FfLoadWait ($x, $y, $pcm, $lbc = 664682)
    Opt("PixelCoordMode", $pcm)
    Local $i
    Local $iColor
    Do
        $iColor = PixelGetColor($x ,$y)
        If $iColor = $lbc Then
            $i = 1
        Else
        Endif
        Sleep(20)
    Until $i = 1
    Do
        $iColor = PixelGetColor($x ,$y)
        If $iColor = $lbc Then
        Else
            $i = 2
        Endif
        Sleep(20)
    Until $i = 2    
EndFunc;==>_FfLoadWait

Example:

#include <FfLoad.au3>

$path = "start your URL"
Run(@ComSpec & " /c " & $path, "", @SW_HIDE)
Opt("WinTitleMatchMode", 2)
WinWait("Mozilla Firefox")
WinSetState("Mozilla Firefox", "", @SW_MAXIMIZE)
_FfLoadWait(820, 732, 1);<<-- Put in your coordinates here
MsgBox(0, "Finished", "Load is finished")
Exit

Edit: Added PixelCoordMode :P

Edit: Update You can now set the colour of loading bar.

FfLoad.au3

Example.au3

Edited by Matrix112

Share this post


Link to post
Share on other sites



I have modified my UDF a little. :P

This UDF waits Max. 30 sec for finish loading and will return 1 if it hasn´t finished.

I won´t update my UDf with this because its only for 30 sec. :mad2:

Just see it as another option if you need to check if it can´t load complete in 30 sec. ;)

FfLoad2.au3

;======================================================================================
;
; Function Name:    _FfLoadWaitTime()
; Description:    Pauses the script until Firefox finished loading. Max. 30 sec.
; Parameter(s):  $x  - The X coordinate of the Blue loading bar.
;                  $y  - The Y coordinate of the Blue loading bar.
;                  $c  - PixelCoordMode
;                        0 = relative coords to the active window
;                        1 = absolute screen coordinates (default)
;                        2 = relative coords to the client area of the active window
; Requirement(s):   Include FfLoad.au3
; Return Value(s):  If loading is not finished in 30 sec the Return is 1 else Return is 0. 
; Author(s):        Christoph Krogmann <ch.krogmann@gmx.de>
; Note(s):        During search for the coordinate, choose a point at the left
;                  side of the loading bar!
;
;======================================================================================
;
Func _FfLoadWaitTime ($x, $y, $c)
    Opt("PixelCoordMode", $c)
    Local $i
    Local $iColor
    Local $isec = @SEC
    Local $istop
    If $isec < 30 Then $istop = $isec + 30
    If $isec = 30 Then $istop = $isec - 29
    If $isec > 30 Then $istop = $isec - 30  
    Do
        $iColor = PixelGetColor($x ,$y)
        If $iColor = 664682 Then
            $i = 1
        Else
        Endif
        Sleep(20)
    Until $i = 1
    Do
        $isec = @SEC
        $iColor = PixelGetColor($x ,$y)
        If $iColor = 664682 Then
            If $isec = $istop Then
                $i = 2
                Return 1
            EndIf   
        Else
            $i = 2
            Return 0
        Endif
        Sleep(20)
    Until $i = 2    
EndFunc;==>_FfLoadWaitTime

Example2.au3

#include <FfLoad2.au3>

$path = "start your URL"
Run(@ComSpec & " /c " & $path, "", @SW_HIDE)
Opt("WinTitleMatchMode", 2)
WinWait("Mozilla Firefox")
WinSetState("Mozilla Firefox", "", @SW_MAXIMIZE)
$load = _FfLoadWaitTime(820, 732, 1);<<-- Put in your coordinates here
If $Load = 1 Then
    MsgBox(0, "Failed", "Load failed")
Else    
    MsgBox(0, "Finished", "Load is finished")
EndIf
Exit

FfLoad2.au3

Example2.au3

Share this post


Link to post
Share on other sites

nice one Matrix....needed one real badly...thank u


I believe we should all pay our tax with a smile. I tried - but they wanted cash!

Share this post


Link to post
Share on other sites

nice one Matrix....needed one real badly...thank u

ok out of the subject

OPERA rocks!!! then comes FF and flock and netscape , finally IE which i personally HATE

but better use this

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Nice to see Firefox scripts.Hope to see more

Edited by xStylezx

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I did a little research and I found out Firefox has a COM-like interface(right word?) you can mess with. Using that, like the IE libraries on here, you can tell (for sure, any skin) if Firefox is loaded.

Also, you should use SetError(), or return negative numbers for exceptions (IMO).

EDIT: Someone already did it for ya :)

http://www.autoitscript.com/forum/index.php?showtopic=20450

Edited by Insolence

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

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