Posts: 1,769
Threads: 410
Joined: Feb 2003
I'm doing something that looks for an accessible object but when it's not found to just keep going. However, it pauses to find the object. I'm not sure what it's doing but is there a way for it to not pause. if it can't find it immediately then just go on and stop holding up the works?
Function
Big_Board
,gmail_acc.Find(gmail_win "PAGETAB" "Inbox \(\d{1,}\)" "class=MozillaWindowClass" 0x1006)
Posts: 12,087
Threads: 142
Joined: Dec 2002
New code:
Selecting tab in firefox
This function is optimized to get Firefox tab info faster.
Function
Firefox4GetTabs
;/
function# hwndFF ARRAY(str)&names [ARRAY(str)&urls]
;Gets names of Firefox tabs. Optionally gets their URL.
;Returns 0-based index of the selected tab. Returns -1 on error.
;hwndFF - Firefox window handle. If 0, finds.
;names - variable for tab names.
;urls - variable for addresses.
;REMARKS
;Tested only with Firefox 4.
;Requires QM 2.3.3 or later.
;EXAMPLE
;ARRAY(str) names urls
;int selectedTab=Firefox4GetTabs(0 names urls)
;out selectedTab
;int i
;for i 0 names.len
,;out "--------[]%s[]%s" names[i] urls[i]
names=0
if(&urls) urls=0
if(!hwndFF) hwndFF=win("Mozilla Firefox" "Mozilla*WindowClass" "" 0x804); if(!hwndFF) ret -1
int i r=-1
FFNode fn
ARRAY(str) ap
;enum tabs
Acc a.Find(hwndFF "PAGETAB" "" "class=MozillaWindowClass" 0x1004)
rep
,if(a.Role!ROLE_SYSTEM_PAGETAB) goto next ;;[ + ] button
,
,names[]=a.Name
,
,;get selected tab
,if(r<0 and a.State&STATE_SYSTEM_SELECTED) r=i
,
,if &urls
,,;get id of associated pane and store in ap. Because the order of tabs and panes may be different.
,,fn.FromAcc(a)
,,ap[]=fn.Attribute("linkedpanel")
,
,;next
,a.Navigate("n"); err break
,i+1
if(!&urls) ret r
;enum panes
urls.create(names.len)
a.Find(hwndFF "DOCUMENT" "" "" 0x3011 2 0 "pa3fi")
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=urls.len) goto next2 ;;should never happen
,;get url and store in urls[i]
,Acc aa; a.Navigate("fi2" aa)
,urls[i]=aa.Value
,
,;next2
,a.Navigate("n"); err break
ret r
err+ ret -1
Posts: 1,769
Threads: 410
Joined: Feb 2003
Posts: 1,769
Threads: 410
Joined: Feb 2003
note: FF 9 has done something different with the tittlebar text when looking at a page where the tab name starts "http" and where it is a "New Tab"
change this
Function
Firefox4GetTabs
if(!hwndFF) hwndFF=win(" - Mozilla Firefox" "Mozilla*WindowClass" "" 0x804); if(!hwndFF) ret -1
to this
Function
Firefox4GetTabs
if(!hwndFF) hwndFF=win("Mozilla Firefox" "Mozilla*WindowClass" "" 0x804); if(!hwndFF) ret -1