Posts: 795
Threads: 136
Joined: Feb 2009
Hi Gintaras,
before I start an endless failure code, is it possible from your opinion to adapt FirefoxGetTabs and siblings routines to Chrome and/or IE?
Posts: 12,141
Threads: 143
Joined: Dec 2002
Posts: 795
Threads: 136
Joined: Feb 2009
Hmm, was quite sure.
As I only keep firefox for those tabs handling features in QM, it's frustrating..
Any hint to mimic those in Chrome or circumvent the limitations?
Posts: 12,141
Threads: 143
Joined: Dec 2002
In Chrome only can get tab button texts. Cannot get page URL and Acc.
In IE maybe can get URL and Acc, but in random order, and cannot reliably know which tab button is for which page. Quite difficult. Probably need different code for different IE versions.
Posts: 795
Threads: 136
Joined: Feb 2009
I've got an idea coming, but just an idea.
What do you advice for handling a string pair, to retreive one from the other.
Memory is not the problem, only speed must be considered...
I want to store Tab name - URL pair, and be able to retreive tab name from URL or URl from a string....
EX
"Quick Macros Forum • Post a reply" "http://www.quickmacros.com/forum/posting.php?mode=reply&f=1&t=6254"
"Google" "www.google.fr"
Efficiency = speed.
Thanks
Posts: 12,141
Threads: 143
Joined: Dec 2002
Macro Macro2508
str csv=
;"Quick Macros Forum • Post a reply", "http://www.quickmacros.com/forum/posting.php?mode=reply&f=1&t=6254"
;"Google", "www.google.fr"
ICsv x._create
x.FromString(csv)
int i=x.Find("www.google.fr" 0 1)
if(i>=0) out x.Cell(i 0)
Posts: 795
Threads: 136
Joined: Feb 2009
OK, numerous ways to do that, wanted the faster.
The idea is to capture tab switch, and store name/url association of active tab, and then do actions depending on tab.
I've got some code quite working, but i see ACC trigger but can't make it work.
Have you got some framework code using that particular trigger with Chrome tabs Acc component?
Posts: 12,141
Threads: 143
Joined: Dec 2002
Try trigger "Window name changed", class Chrome_WidgetWin_1.
Posts: 795
Threads: 136
Joined: Feb 2009
yes that is what my current code uses, but i'd like to use ACC trigger, maybe much accurate
Posts: 12,141
Threads: 143
Joined: Dec 2002
Macro Macro2510
Trigger $a 130 0 "" "Chrome_RenderWidgetHostHWND" "" "" "Chrome_WidgetWin_1"
;\
function hwnd idObject idChild
;Runs on SHOW event of tab child window.
Acc a.FromEvent(hwnd idObject idChild)
out a.Name
;get URL
Acc aDoc.Find(a.a "DOCUMENT" "" "" 0x3000)
out aDoc.Value
Posts: 795
Threads: 136
Joined: Feb 2009
yep, almost there...
Need to act on an already opened tab name change (i.e click a bookmark from it)
Possible?
Posts: 12,141
Threads: 143
Joined: Dec 2002
Can use NAMECHANGE event, but it is the same as "Window -> Name changed" trigger.
Posts: 795
Threads: 136
Joined: Feb 2009
Damned, worked for a while and now doesn't anymore, grrrr
Posts: 795
Threads: 136
Joined: Feb 2009
OK, the last version did work for some minutes, and then errored each time at document retreiving step. The name output was always chrome's one, not the tab text...
reverted to name change on window trigger, and works each time, but damned slow...
Hint to speed it up?
Posts: 12,141
Threads: 143
Joined: Dec 2002
Check "reverse".
Macro Macro2514
Trigger !n"" "Chrome_WidgetWin_1" "" "Chrome_RenderWidgetHostHWND" /CHROME
int hwnd=TriggerWindow
out _s.getwintext(hwnd)
Acc a.Find(hwnd "TEXT" "Address and search bar" "class=Chrome_WidgetWin_1[]state=0x100000 0x20000040" 0x1085)
out a.Value
Posts: 795
Threads: 136
Joined: Feb 2009
not sure it speeds the stuff, but i'll set it.
For Macro2510, here is the output
Chrome Legacy Window
Error (RT) in <open ":2852: /144">Function5: object not found.
For the CSV, i'd like to have global variable, initialized when Chrome is launched, and destroyed (epmtied) when chrome is closed
I created Function 1 -> Triggered by Chrome launch
In it, i put
ICsv+ x
ICsv x._create
Function 2 ->Triggered by Chrome destroyed
In it I put
ICsv+ x
x.Clear
Is it correct?
Posts: 12,141
Threads: 143
Joined: Dec 2002
ICsv is not thread-safe. Use lock when accessing the variable.
Func1:
ICsv+ g_csv18547
g_csv18547._create
Func2:
ICsv+ g_csv18547
g_csv18547=0
Posts: 12,141
Threads: 143
Joined: Dec 2002
Also try this.
Macro Macro2513
out
int w=win("" "Chrome_WidgetWin_1")
Acc aPTL.Find(w "PAGETABLIST" "" "" 0x1084)
int i nTabs=aPTL.ChildCount-1
spe 10
act w
rep nTabs
,Acc aAB.Find(w "DOCUMENT" "" "" 0x3000 3)
,str name url
,name=aAB.Name
,url=aAB.Value
,out F"name='{name}'[] url='{url}'"
,
,key CT ;;next tab
Posts: 795
Threads: 136
Joined: Feb 2009
1. use lock even when creating or putting it to 0 or when using it in code??
i.e function3
ICsv+ x
lock x
sample code
using x
here
lock- x
2.
Acc a.FromMouse
a.Role(_s)
out _s
always returns CLIENT whatever the mouse is pointing at.
Works normally in Firefox, and accessible windows action window finds anything in the page (text, link, picture etc etc).
Some tweaks involved?
Not so easy to move from firefox to chrome in this purpose :/
Posts: 795
Threads: 136
Joined: Feb 2009
Macro2513 was my very first attempt, but inconvinient and slow..
The change name trigger is far more efficient IMHO
Posts: 12,141
Threads: 143
Joined: Dec 2002
1. Use lock when it is possible that 2 or more threads can use the variable simultaneously. If unsure, lock everywhere.
2. Chrome starts with disabled accessible objects. Acc.Find auto-enables, as well as the Acc capture dialog. But Acc.FromMouse doesn't, it would be too slow. To start Chrome with enabled accessible objects, use command line --force-renderer-accessibility.
Posts: 795
Threads: 136
Joined: Feb 2009
1. ok, but is the syntax code provided
2. yes, forgot that trick, used in the past...much better now...
more questions coming
Posts: 12,141
Threads: 143
Joined: Dec 2002
Quote:not sure it speeds the stuff, but i'll set it.
Quote:Error (RT) in <open ":2852: /144">Function5: object not found.
Macro Macro2514
Trigger !n"" "Chrome_WidgetWin_1" "" "Chrome_RenderWidgetHostHWND" /CHROME
int hwnd=TriggerWindow
Acc a.Find(hwnd "DOCUMENT" "" "" 0x3000 1)
out a.Name
out a.Value
Quote:1. ok, but is the syntax code provided
The code is correct. lock- usually is optional.
Posts: 795
Threads: 136
Joined: Feb 2009
new macro 2514 is faster, but don't trigger on name change..will try to mix...
Posts: 795
Threads: 136
Joined: Feb 2009
Damned..
Function SourisMilieuChrome
Trigger F8 /CHROME
Acc k
POINT+ _m; xm _m
Acc aa.ObjectFromPoint(_m.x _m.y 2 &k)
k.Role(_s)
out _s
works from hotkey (F8)
But i want to use it from a mouse middle click in chrome window.
In this case, alaways returns CLIENT, whatever the Role is...
Posts: 12,141
Threads: 143
Joined: Dec 2002
The same with accessible trigger.
Macro Macro2517
Trigger $a 140 0 "" "Chrome_WidgetWin_1"
;\
function hwnd idObject idChild
Acc aw.FromEvent(hwnd idObject idChild)
;out aw.Name
Acc a.Find(hwnd "DOCUMENT" "" "" 0x3000 1)
out a.Name
out a.Value
Does not trigger when two tabs have same name. Or when URL changes but name doesn't.
Posts: 12,141
Threads: 143
Joined: Dec 2002
Works here.
Macro Macro2518
Trigger #M 0x8
Acc a.FromMouse
a.Role(_s)
out _s
In some windows does not work in a filter function.
Posts: 795
Threads: 136
Joined: Feb 2009
found the problem : function handling middle click must be called
to work..
mac "middleclick"
instead of directly
middleclick
.... why???
Posts: 12,141
Threads: 143
Joined: Dec 2002
Then with wait also should work, if not in a filter-function.
wait 1
Acc a.FromMouse
a.Role(_s)
out _s
Posts: 795
Threads: 136
Joined: Feb 2009
the generic middle click action function is anyway...
but works like that..
it's becoming possible to migrate my functions to chrome, even is a little tricky \o/
Another one : is there a way to monitor when page is fully loaded in chrome (my guess : no)..
|