Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Firefox page load wait



  • Please log in to reply
45 replies to this topic
col_mik
  • Members
  • 171 posts
  • Last active: Aug 29 2015 03:29 PM
  • Joined: 28 Jun 2015

I'll be watching this thread for further updates too.  Some sort of mini-tutorial would be really useful - even if it's just a few links to where the information was found.

For those interested in FireFox, I also made this discovery, which I have found useful (when using FF, send page source to clipboard, where it can then be parsed)



edison
  • Members
  • 29 posts
  • Last active: May 10 2015 11:15 PM
  • Joined: 13 Feb 2013

Do I have a chicken's chance in Thailand that you might teach me how you did that? :-P  I'd like to grab other text

 

Sergio, what text are you looking to grab? Take a look here:

 

http://www.autohotke...20/#entry495073



col_mik
  • Members
  • 171 posts
  • Last active: Aug 29 2015 03:29 PM
  • Joined: 28 Jun 2015

The script didn't run because I'm missing Acc.ahk.

I have spent a while looking for it, but all I found was a link here that seems to be broken.

I saw it was written by Sean, so I looked him up in the member list, hoping to find Acc in his content, but his profile reports no content, and no posts.

 

Would you be so kind as to post a link to Acc.?

 

Thanks ... Colmik.



edison
  • Members
  • 29 posts
  • Last active: May 10 2015 11:15 PM
  • Joined: 13 Feb 2013

The script didn't run because I'm missing Acc.ahk.

I have spent a while looking for it, but all I found was a link here that seems to be broken.

I saw it was written by Sean, so I looked him up in the member list, hoping to find Acc in his content, but his profile reports no content, and no posts.

 

Would you be so kind as to post a link to Acc.?

 

Thanks ... Colmik.

 

There was a link to the ACC Library in the Accessibility Viewer link I posted: http://www.autohotke...dated-09272012/



col_mik
  • Members
  • 171 posts
  • Last active: Aug 29 2015 03:29 PM
  • Joined: 28 Jun 2015

Thanks, Edison,

 

Got it.



edison
  • Members
  • 29 posts
  • Last active: May 10 2015 11:15 PM
  • Joined: 13 Feb 2013

For what it's worth, I'm still working on perfecting a version of FFwait() that works reliably on FF20+.

 

For some reason, the reload button tool tip ACC object is difficult to fetch every time. Either it doesn't exist, or ACC can't get to it. Sometimes the path to the tool tip just isn't there, so it makes checking its value considerably more challenging. I've added some debugging and am using DebugView to try to narrow down why it's failing.



jethrow
  • Moderators
  • 2854 posts
  • Last active: May 17 2017 01:57 AM
  • Joined: 24 May 2009
Fyi - the path shouldn't be an issue with UIA - just sayin...

edison
  • Members
  • 29 posts
  • Last active: May 10 2015 11:15 PM
  • Joined: 13 Feb 2013

Fyi - the path shouldn't be an issue with UIA - just sayin...

 

Is there an AHK interface to UIA?



jethrow
  • Moderators
  • 2854 posts
  • Last active: May 17 2017 01:57 AM
  • Joined: 24 May 2009

Is there an AHK interface to UIA?

 
UIA provides a COM interface - but not IDispatch. You might appreciate this:

FFWait() {
	static uia := UIA_Interface() ;// https://github.com/jethrow/UIA_Interface
	,	c := uia.CreateAndConditionFromArray([	uia.CreatePropertyCondition(30003, 50000, 3)
						,	uia.CreatePropertyCondition(30092, "Location", 8)
						,	uia.CreateOrCondition(	uia.CreatePropertyCondition(30094,"Reload current page",8)
									,	uia.CreatePropertyCondition(30094,"Stop loading this page",8))	])
	WinGet, hwnd, ID, ahk_class MozillaWindowClass
	ff := uia.ElementFromHandle(hwnd)
	while ff.FindFirst(c,0x4).GetCurrentPropertyValue(30094) != "Reload current page"
		sleep 10
}

Note - this example assumes that the (button) UIA Element's LegacyIAccessiblePattern.Description will be either "Reload ..." or "Stop ..." - which I'm sure you can understand. Also note that the UIA library is a work in progress - the syntax for the library objects may change.



bruno
  • Members
  • 635 posts
  • Last active: Nov 04 2015 02:26 PM
  • Joined: 07 Mar 2011

FindClick() implementation works but any definitive code-based as-above approach update that consistently works with Firefox?



alaskanjackal
  • Members
  • 4 posts
  • Last active: Feb 17 2016 11:46 PM
  • Joined: 10 May 2015

Sorry to bump after so long, but has anyone had success with newer versions of FF?

 

(Big thanks to Colmik for posting that link to Easy Copy--that solved another issue I was trying to fix.)

 

The older script posted by edison in post #22 seems to no longer work (script loads successfully; it just doesn't recognize that the page hasn't loaded and the script just moves on), and I can't make sense of the snippet posted by jethrow in post #39 (just a straight copy and paste of that into my script results in a call to a nonexistent function when loading the script, and troubleshooting what's missing is beyond my abilities at this point.

 

All that said, I'm not above downgrading FF to something old to make this work, but if this can be made to work in modern FF (running 36.0 now), that would be awesome!



edison
  • Members
  • 29 posts
  • Last active: May 10 2015 11:15 PM
  • Joined: 13 Feb 2013

I don't know that I've tweaked the last-posted version, but I'm currently properly waiting for FF page loads. Super swamped right now, but I'll see if I can extract the function and post it in a few days. Ping me if I forget about it.



alaskanjackal
  • Members
  • 4 posts
  • Last active: Feb 17 2016 11:46 PM
  • Joined: 10 May 2015

No worries--it was a fairly simple fix: the stop/reload button had moved yet again in some recent FF update.

 

For posterity, here's what is working for me as of FF36 (contents of FFwait.ahk in my script directory)--note the last uncommented "button" line:

#Include %A_ScriptDir%\Acc.ahk

;
; FFwait - wait for a Firefox page to finish loading
;
; Requires:
;     Acc.ahk
;
FFwait() {
    WinWaitActive, ahk_class MozillaWindowClass

    ; define path to page load status push button
    ; the button's description will change when the page has finished loading
    ;button := "application.grouping2.property_page1.tool_bar2.combo_box1.push_button4"
    ; may require the path below for newer Firefox versions
    ;button := "application.tool_bar2.combo_box1.push_button4"
     button := "application.tool_bar22.combo_box3.push_button5"

    ; the description text that indicates page load status
    ;
    ; note that these may change - mouse over the button to see what your
    ; Firefox shows in the tooltip
    loading := "Stop loading this page"
    loaded  := "Reload current page"

    ; sleep until the description indicates page is loaded
    while description := Acc_Get("Description", button, 0, "ahk_class MozillaWindowClass") {
            if (description = loaded) {
                    break
            }
            sleep, 10
    }

    return
}


alaskanjackal
  • Members
  • 4 posts
  • Last active: Feb 17 2016 11:46 PM
  • Joined: 10 May 2015

OK, I spoke too soon. I was testing on an actual slow connection (where this actually makes a difference) and the script is not actually waiting until FF is done loading.

 

I tried to put a "MsgBox, %description%" in the FFwait script to show the description and see if the failure to grab the description is the cause of the issue, but it didn't pop up any MsgBox:

while description := Acc_Get("Description", button, 0, "ahk_class MozillaWindowClass") {
            MsgBox, %description%
            if (description = loaded) {
                    break
            }
            sleep, 10
    }

Though actually, I suppose the FFwait script should never proceed if the description != loaded, so that's not likely the cause of it.

 

A MsgBox inserted at the beginning of the FFwait script does pop up when I run my regular script, so FFwait is being called--it's just apparently skipping the "while" statement as far as I can tell.



alaskanjackal
  • Members
  • 4 posts
  • Last active: Feb 17 2016 11:46 PM
  • Joined: 10 May 2015

Last update, hopefully. It was a simple issue with the button path. I had thought they were identified with the numbers next to the list in the Acc Structure window of AccViewer--turns out they're just counted cumulatively from the top. I changed it to the following and it works perfectly now, both on slow and fast connections:

 

button := "application1.tool_bar3.combo_box1.push_button3"

 

(This works with FF36.)