i have alittle problem with this code given in Acc.GetChildObjects help.
get name/URL of all Firefox tabs
int w=win("Mozilla Firefox" "Mozilla*WindowClass" "" 0x804)
Acc a.Find(w "DOCUMENT" "" "" 0x3010 2 0 "parent3") ;;find current DOCUMENT and get its parent GROUPING
ARRAY(Acc) b; int i
a.GetChildObjects(b 2 "DOCUMENT" "" "" 16) ;;get all child DOCUMENT at level 2, including hidden
for i 0 b.len
out "--------"
out b[i].Name ;;page name
out b[i].Value ;;page URL
if(b[i].State&STATE_SYSTEM_INVISIBLE=0) out "<visible>"
I found it working perfectly as long as a web page has content, empty DOCUMENT webpage throw exception , which is normal due to the 0x3010 flag.
For example, my firefox homepage is Speed dial, which have an APPLICATION property in place of DOCUMENT. If I test the above code with a tab containig speeddial page
it does not work.
I'd like the code to skip the first faulty tab, and begin enumeration from another tab which does have a DOCUMENT property to retreive all tabs.
In fact, it's a short version of the problem which actually reside in the FirefoxGetTabs , but the solution for this one should apply to it too.
Change flags to 0x1010. Slower but works.
With flag 0x2000, finds root object of current web page. It is fast, because goes directly to the object. However fails if root object of current page is not DOCUMENT, if DOCUMENT is specified.
Without the flag, searches all object three until finds a DOCUMENT, therefore is slow.
This also works, and is fast. Will not work if current page is completely empty, but i never saw such web pages in Firefox.
Macro Macro1862
Gintaras Wrote:Change flags to 0x1010. Slower but works.]
Yes solve the problem, did try many flags variations, but not this one....
Gintaras Wrote:With flag 0x2000, finds root object of current web page. It is fast, because goes directly to the object. However fails if root object of current page is not DOCUMENT, if DOCUMENT is specified.
Without the flag, searches all object three until finds a DOCUMENT, therefore is slow.
This one fails.
Gintaras Wrote:This also works, and is fast. Will not work if current page is completely empty, but i never saw such web pages in Firefox.
Macro Macro1862
Acc a.Find(w "" "" "" 0x3010 0 0 "parent4")
Don't use this. In next QM it will find the root object, and this code will not work. It is a bug if it does not find the root object if role is not specified, and will be fixed. Wait, I'll give something better.
out ;get name/URL of all Firefox tabs int w=win("Mozilla Firefox""Mozilla*WindowClass"""0x804) Acc a.FindFirefoxWebRoot(w); a.Navigate("parent3") ARRAY(Acc) b;int i
a.GetChildObjects(b 2"DOCUMENT"""""16);;get all child DOCUMENT at level 2, including hidden for i 0 b.len ,out"--------" ,out b[i].Name ;;page name ,out b[i].Value ;;page URL ,if(b[i].State&STATE_SYSTEM_INVISIBLE=0)out"<visible>"
In FirefoxGetTabs replace line a.Find(hwndFF "DOCUMENT"... with:
Function FirefoxGetTabs
Gintaras Wrote:Can get URL only of loaded pages. New Firefox versions don't load pages in invisible tabs at startup.
Yes I fully understand that. I just want the FirefoxGetTabs be able to skip the tab that contains no DOCUMENT property in iteration, so it does not
appears in list, and without generating any error. I don't have the use of empty webpage.
rep
get id of this pane, and find in ap
fn.FromAcc(a); _s=fn.Attribute("id")
for(i 0 ap.len) if(ap[i]=_s) break
if(i=names.len) goto next2 ;;should never happen
get DOCUMENT object and url
Acc aa; a.Navigate("fi2" aa)
if(&urls) urls[i]=aa.Value
if(&docObjects) docObjects[i]=aa
next2
a.Navigate("n"); err break
ret r
In this, if document not present, then I have logically a "object not found" error, terminating the routine (as asked by the code, no problem here).
I'd like to continue iteration of through other tabs and discard the empty one.
fails because the current selected tab from which iteration through tab set begins, how to begin with another one, until I find a
valid one containing DOCUMENT property?
a.Find(hwndFF "DOCUMENT" "" "" 0x1010 2 0 "pa3fi") <====================reverted to that (the new function does not work, generate error)
rep
get id of this pane, and find in ap
fn.FromAcc(a); _s=fn.Attribute("id")
for(i 0 ap.len) if(ap[i]=_s) break
if(i=names.len) goto next2 ;;should never happen
get DOCUMENT object and url
Acc aa; a.Navigate("fi2" aa)
err goto next2 ;; <==================== added this to bypass the aa object not existing
if(&urls) urls[i]=aa.Value
if(&docObjects) docObjects[i]=aa