Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Firefox ACC current tab
#1
how do i use ACC to return to the tab where i started my macro?

i need to activate the tab from where i started my actions to run another loop of actions.
in firefox i use a userscript which can be triggered by key press, i give qm a number for rep to send keys (key CQ ;; next tab),
when finished i now send key for the amount of new tabs-1 (key SCT), but simply activating the start-tab would be better.

thanks
pi
#2
Macro Macro1867
Code:
Copy      Help
int w=win("Firefox" "Mozilla*WindowClass" "" 0x804)
act w

;get current tab name
Acc a.Find(w "DOCUMENT" "" "" 0x3000 2)
str tabName=a.Name

;next tab
key CT
1

;return to the tabName tab
Acc a1.Find(w "PAGETAB" tabName "" 0x1005)
a1.DoDefaultAction
#3
sweet!

how do i gather all info from PAGETABLIST? seems that each tab has a unique ID -> a:linkedpanel=panel{someNumberGeneratedByFirefox} and where to put best (array, class, some other kind of structure)
when using unique ID then i would not have to rely on tab title.

how to checked if a tab has finished loading?
and how would i navigate with acc instead of sending key CT?
pi
#4
Maybe you already have this function. It somewhere in forum. It uses these linkedpanel to get web page of tab button.
Function FirefoxGetTabs
Code:
Copy      Help
;/
function# [hwndFF] [ARRAY(str)&names] [ARRAY(str)&urls] [ARRAY(Acc)&docObjects] [ARRAY(Acc)&buttonObjects]

;Gets names of Firefox tabs. Optionally gets their URL and accessible objects.
;Returns 0-based index of the selected tab.
;Error if fails.

;hwndFF - Firefox window handle. If 0, finds.
;names - variable for tab names. Can be 0 if don't need.
;urls - variable for addresses. Can be 0 if don't need.
;docObjects - variable for DOCUMENT accessible objects that represent web pages. Can be 0 if don't need.
;buttonObjects - variable for PAGETAB accessible objects that represent tab buttons. Can be 0 if don't need.

;REMARKS
;Requires QM 2.3.3 or later.
;Elements of urls and docObjects of non-loaded tabs will be empty. Firefox does not load pages in invisible tabs at startup.

;EXAMPLE
;ARRAY(str) names urls
;int selectedTab=FirefoxGetTabs(0 names urls)
;out selectedTab
;int i
;for i 0 names.len
,;out "--------[]%s[]%s" names[i] urls[i]


ARRAY(str) _names; if(!&names) &names=_names
names=0
if(&urls) urls=0
if(&docObjects) docObjects=0
if(&buttonObjects) buttonObjects=0

if(!hwndFF) hwndFF=win("Mozilla Firefox" "Mozilla*WindowClass" "" 0x804); if(!hwndFF) end ERR_WINDOW

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
,if(&buttonObjects) buttonObjects[]=a
,
,;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(r<0) end ERR_FAILED
if(!&urls and !&docObjects) ret r

;enum panes
if(&urls) urls.create(names.len)
if(&docObjects) docObjects.create(names.len)
#if QMVER<0x2030400
a.Find(hwndFF "DOCUMENT" "" "" 0x3000 0 0 "pa3fi")
err a.Find(hwndFF "" "" "" 0x3010 1 0 "pa4fi")
#else
a.Find(hwndFF "" "" "" 0x3000 2 0 "pa3fi")
#endif
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
,if(&urls) urls[i]=aa.Value
,if(&docObjects) docObjects[i]=aa
,
,;next2
,a.Navigate("n"); err break

ret r

err+ end _error

Also this maybe will be useful.
Function FirefoxSelectTab
Code:
Copy      Help
;/
function hwndFF $name [flags] ;;flags: 1 name is URL, 2 wildcard, 4 beginning, 8 end, 16 anywhere, 32 rx

;Finds and selects Firefox tab.
;Error if not found.

;hwndFF - Firefox window handle. If 0, finds.
;name - tab name. If flag 1 - URL.
;flags:
;;;1 - name is URL.
;;;2-32 - how to compare name. Default: exact match. Always case insensitive.


ARRAY(str) names urls; ARRAY(Acc) a
int selectedTab=FirefoxGetTabs(hwndFF names iif(flags&1 &urls 0) 0 a)
int i
ARRAY(str)& as=iif(flags&1 urls names)
for i 0 names.len
,if SelStr(flags|1 as[i] name)
,,if i!=selectedTab
,,,a[i].DoDefaultAction
,,ret 1

end "tab not found"
err+ end _error

Quote:how to checked if a tab has finished loading?
With current tab - function FirefoxWait, look in this forum.
Probably not possible with background tabs. FF fires an accessible event, but it is not reliable.


Forum Jump:


Users browsing this thread: 5 Guest(s)