AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

if(FirefoxIsDoneWithLoadingWebsite)

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
GDur



Joined: 15 Nov 2009
Posts: 82
Location: Berlin

PostPosted: Thu Dec 31, 2009 11:58 am    Post subject: if(FirefoxIsDoneWithLoadingWebsite) Reply with quote

i that i can make it wth a imagesearch but thats not good when the solution changes..

i'am searching for a solution with a pseudocode like that:

Code:
1. run, google.de
2. wait until firefox "WM_PAINT"'s
3. then wait until firefox for (as example) 100ms not "WM_PAINT"'s and then do something.


when firefox doesn't "WM_PAINT" anymore, it should signal that firefox is done with loading of the website..

someone got an idea how i can proof that firefox "WM_PAINT"'s ?

or somebody got a better solution?
_________________
*can't live without AHK*
Back to top
View user's profile Send private message MSN Messenger
Sergio



Joined: 16 Mar 2008
Posts: 160
Location: Brooklyn

PostPosted: Thu Dec 31, 2009 8:18 pm    Post subject: Reply with quote

This topic comes up at least once a week. Please check the forums.

There are plenty of workarounds. Everyone has their own formula. But there isn't a standardized method to implement for FF.
_________________
Back to top
View user's profile Send private message
hardcider09



Joined: 26 Mar 2009
Posts: 15

PostPosted: Fri Jan 01, 2010 3:27 pm    Post subject: Re: if(FirefoxIsDoneWithLoadingWebsite) Reply with quote

GDur wrote:
i that i can make it wth a imagesearch but thats not good when the solution changes..

i'am searching for a solution with a pseudocode like that:

Code:
1. run, google.de
2. wait until firefox "WM_PAINT"'s
3. then wait until firefox for (as example) 100ms not "WM_PAINT"'s and then do something.


when firefox doesn't "WM_PAINT" anymore, it should signal that firefox is done with loading of the website..

someone got an idea how i can proof that firefox "WM_PAINT"'s ?

or somebody got a better solution?


A solution that has worked very well for me was to install an add-on for Firefox called Fission, which changes the color of the address bar as Firefox loads a page. Then I use the PixelGetColor command to monitor the color change.
Back to top
View user's profile Send private message
GDur



Joined: 15 Nov 2009
Posts: 82
Location: Berlin

PostPosted: Fri Jan 01, 2010 4:45 pm    Post subject: Reply with quote

Sergio wrote:
This topic comes up at least once a week. Please check the forums.

There are plenty of workarounds. Everyone has their own formula. But there isn't a standardized method to implement for FF.

but WM_PAINT all firefox versions do
so it should work
_________________
*can't live without AHK*
Back to top
View user's profile Send private message MSN Messenger
GDur



Joined: 15 Nov 2009
Posts: 82
Location: Berlin

PostPosted: Fri Jan 01, 2010 7:55 pm    Post subject: Re: if(FirefoxIsDoneWithLoadingWebsite) Reply with quote

hardcider09 wrote:
GDur wrote:
i that i can make it wth a imagesearch but thats not good when the solution changes..

i'am searching for a solution with a pseudocode like that:

Code:
1. run, google.de
2. wait until firefox "WM_PAINT"'s
3. then wait until firefox for (as example) 100ms not "WM_PAINT"'s and then do something.


when firefox doesn't "WM_PAINT" anymore, it should signal that firefox is done with loading of the website..

someone got an idea how i can proof that firefox "WM_PAINT"'s ?

or somebody got a better solution?


A solution that has worked very well for me was to install an add-on for Firefox called Fission, which changes the color of the address bar as Firefox loads a page. Then I use the PixelGetColor command to monitor the color change.


this seems to be a nice idea...got the addon now too...
and if there's nobody who got any idea how i can check the wm_paint signals from firefox then i will use your idea
thanks
_________________
*can't live without AHK*
Back to top
View user's profile Send private message MSN Messenger
Stupidity
Guest





PostPosted: Wed Aug 11, 2010 2:40 am    Post subject: This might help Reply with quote

I have been hopelessly lurking the forum for a valid solution that would be up to date.

I simply applied the script a another user: pajeen
(sorry if the name is incorrect. He/She deserves all the credit)

(Look up the ScreenGrab OCR thread.)
(you will need to download the things that he did)
(If no one can find this, ill upload a copy)

either way, I thought to myself, why not use OCR to detect when ff finished loading?

Note: I used 1024 X 768
But, the coordinates can easily be modified Cool

Code:

;==This has been modified to tell when a page has loaded=====
ReloadScript = 0
WaitForDone:
if ReloadScript >= 1
{
Reload
}
Loop
{
; Requires gocr or tesseract, mkbitmap, potrace, and imagemagick.
; Default variables
; Temporary file options
FileCreateDir, %A_ProgramFiles%\gocr\tmp
TmpDir = %A_ProgramFiles%\gocr\tmp
TmpFile = image_out

; mkbitmap options
mkbitmap = 1 ; 1, Preprocess screen grab using mkbitmap. 0, false.
mkbitmap_path = %A_ProgramFiles%\gocr
mkb_i = ; -i, inversion. Blank by default.
mkb_f = 4
mkb_n = ; -n, nofilter. Turns off highpass filtering. Blank by default.
mkb_s = 2
mkb_interpolation = "-1" ; "-3" or "-1". Cubic or linear interpolation. "-1" yields better results for text.
mkb_t = 0.45
mkb_g = ; -g, grey. Only scales and greymaps the image. Blank by default.

; potrace options
potrace = 1 ; 1, Preprocess screen grab using potrace. 0, false.
potrace_path = %A_ProgramFiles%\gocr
pot_z = minority ; black, white, right, left, minority, majority, random
pot_t = 0
pot_a = 1
pot_n = ; Blank by default. "-n" turns off curve optimization.
pot_O = 0.2
pot_u = 10

app = "gocr"

; gocr options
gocr_path = %A_ProgramFiles%\gocr
gocr_s = 0
gocr_d = -1
gocr_m = 32
gocr_n = 0

; tesseract options
convert_path = %A_ProgramFiles%\gocr
tesseract_path = %A_ProgramFiles%\gocr

; Needs four variables representing the points needed for the scan.
; A set of coordinates for the upper left corner of the scan area (the origin), and a set for the lower right corner of the scan area.
; Represented by scan_x_start, scan_y_start, scan_x_end, scan_y_end.

CoordMode, Pixel, Relative    ; Sets pixel actions relative to coordinates of the full desktop window or the active window. Use the mode that you used to obtain the starting and ending coordinates of the image area.

scan_x_start = 6
scan_y_start = 723
scan_x_end = 36
scan_y_end = 738

scan_current_x = %scan_x_start%   ; Sets the starting x point of the scan. The origin of the window is the upper left corner.
scan_current_y = %scan_y_start%   ; Sets the starting y point of the scan.

BlockInput, On

Loop
{
   scan_current_y++
   if scan_current_y > %scan_y_end%
   {
      Break
   }
   Loop
   {
      scan_current_x++
      if scan_current_x > %scan_x_end%
      {
         Break
      }
   
      PixelGetColor, current_pixel_color, %scan_current_x%, %scan_current_y%, RGB
     
      StringMid, current_pixel_r, current_pixel_color, 3, 2
      StringMid, current_pixel_g, current_pixel_color, 5, 2
      StringMid, current_pixel_b, current_pixel_color, 7, 2
     
      ; Need to turn the value returned into a hexadecimal value.
     
      current_pixel_r = 0x%current_pixel_r%
      current_pixel_g = 0x%current_pixel_g%
      current_pixel_b = 0x%current_pixel_b%
     
      SetFormat, integer, d
      ; Need to perform a math operation using the variables in order to get them in integer decimal format.
      current_pixel_r -= 0
      current_pixel_g -= 0
      current_pixel_b -= 0
     
      current_pixel_r := " " . current_pixel_r
      current_pixel_g := " " . current_pixel_g
      current_pixel_b := " " . current_pixel_b
     
      image_data = %image_data% %current_pixel_r% %current_pixel_g% %current_pixel_b%
   }
   
   image_data = %image_data% `n
   
   scan_current_x = %scan_x_start%
}

BlockInput, Off

format := "P3`n", comment := "# File made using AutoHotkey.`n", width := scan_x_end - scan_x_start, height := scan_y_end - scan_y_start, max_colors := 255

file_data = %format% %comment% %width% %height% `n %max_colors% `n %image_data%

; Clean old temporary files.
IfExist %TmpDir%\%TmpFile%.ppm
{
   FileDelete %TmpDir%\%TmpFile%.ppm
}
; End of cleaning.

FileAppend, %file_data%, *%TmpDir%\%TmpFile%.ppm
ImageFormat = "ppm"

If mkbitmap = 1
{
   RunWait, %mkbitmap_path%\mkbitmap.exe %mkb_i% -f %mkb_f% %mkb_n% -s %mkb_s% %mkb_interpolation% -t %mkb_t% %mkb_g% "%TmpDir%\%TmpFile%.ppm" -o "%TmpDir%\%TmpFile%.pbm", %mkbitmap_path%, hide,
   ImageFormat = "pbm"
}

If potrace = 1
{
   RunWait, %potrace_path%\potrace.exe -z %pot_z% -t %pot_t% -a %pot_a% %pot_n% -O %pot_O% -u %pot_u% -g -o "%TmpDir%\%TmpFile%.pgm" "%TmpDir%\%TmpFile%.%ImageFormat%", %potrace_path%, hide,
   ImageFormat = "pgm"
}

If app = "gocr"
{
   RunWait, %gocr_path%\gocr.exe -i "%TmpDir%\%TmpFile%.%ImageFormat%" -s %gocr_s% -d %gocr_d% -m %gocr_m% -n %gocr_n% -o "%TmpDir%\%TmpFile%.txt", %gocr_path%, Hide,
}
FileReadLine, IsPageLoaded, %A_ProgramFiles%\gocr\tmp\image_out.txt, 1
StringReplace, IsPageLoaded, IsPageLoaded, %A_SPACE%,, All
StringReplace, IsPageLoaded, IsPageLoaded, _,, All
StringReplace, IsPageLoaded, IsPageLoaded, ?,, All
FileRemoveDir, %A_ProgramFiles%\gocr\tmp, 1

If IsPageLoaded = Done
Break
else
{
Sleep, 2500
ReloadScript +=1
Goto, WaitForDone
}
}
MsgBox, The Rest of the script goes here.
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group