Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Browser toolbar
Hi Gintaras, hi all

I need to be steered to the right way.

I want to implement a toolbar, containing changing text based on browser titlebar.

I don't know how to dynamicaly change toolbar text item.

Collected QM apps, functions, samples

Look for
Yes, good way to begin with...

Is there a function to monitor a specific Acc object change, like the url bar of firefox or chrome (where the url is set)??
Trigger 'window name changed' or an accessible object trigger.
Tried accessible object trigger with no joy sooo many times..if any example, would be happy
Function firefox_address_text_changed
Trigger $a 142 -4 "" "MozillaWindowClass" "" "*- Mozilla Firefox" "" "" 42 "" "Search or enter address" "" "" 0x20     Help - how to add the trigger to the macro
Copy      Help
function hwnd idObject idChild
Acc a.FromEvent(hwnd idObject idChild)
out a.Value
hmm, nearly perfectly in firefox after tweaking language Acc name...

but i don't want to use firefox anymore, and when adapted for chrome does not work, any hint???

trigger for chrome:

$a 142 -4 "" "Chrome_WidgetWin_1" "" "*- Google Chrome" "" "" 42 "" "Barre d'adresse et de recherche" "" "" 0x20

Function chrome_address_text_changed
Trigger $a 140 -4 "" "Chrome_WidgetWin_1" "" "*- Google Chrome" "" "" 42 "" "Address and search bar" "" "" 0x20     Help - how to add the trigger to the macro
Copy      Help
function hwnd idObject idChild
Acc a.FromEvent(hwnd idObject idChild)
out a.Value
Seems to work in chrome when triggers is based on NAMECHANGE and not VALUECHANGE as in firefox, although the url is in the value property of the Acc object..

do you know why????

EDIT : crossed replies...
ok, last piece of the puzzle.

The framework of the project is to mimic this:

on tab change, QM changes a toolbar linked to chrome button name (as the first question of the thread).

What is the best implemetation for the storage of the datas?

Should a couple like


Do I use a CVS, a stringmap or something else? The goal is the speed in this case

TAB Change -> Read data -> matching text for given URL

The procedure must be able to change text associated to URL on the fly, and be loaded/saved when chrome starts/ends (to preserve the informations)
IStringMap or ICsv.
Use IStringMap if expected large number of items, else both are good. If very very large number, use Sqlite.
would be <500 items
i forgot to ask, how create a file from a stringmap object????

I can get items from a string variable (AddList function) but what is the opposite procedure?
yes, but it's the stringmap -> string procedure i miss

must use an intermediate array, or can i do it directly?
str.getfile; IStringMap.AddList ... IStringMap.GetList; str.setfile
ok, missed the GetList function, sorry
ok, some letters in the file text are messed, and the string when read is not the good one
I suspect an encoding problem


is météo in the file.

How fix that??
Open the file in notepad and save as UTF-8.
Or use str.ConvertEncoding.
ok, fixed...

is it possible to create from code a UTF8 text file, convertencoding asks for a encoding code prior to do it, and not sure which one my system uses
setfile creates utf8 file if checked Unicode in Options.
yes, it is..problem solved..
as it can be very fast used code, and text file is read/written each time the function is called, i want to ensure there is no corruption and/or bad write/reading of datas.

The triggered QM code is in a function, and i ticked the "only single thread" option of this function.

Must I too use lock in the function???

function hwnd idObject idChild

Acc a.FromEvent(hwnd idObject idChild)


str url=a.Value
some code
_s.getfile("q:\test.txt" 0 -1)
IStringMap m._create
some code
f.setfile("q:\test.txt"0 -1)

I think 'lock' should be used, as it is in your code, and don't need "only single thread".
ok, ty
But frequent getfile/setfile is not good, especially when the file is big.
Other options:
Use a global IStringMap variable and save it to file less frequently.
Maybe use registry functions instead.
Or a global Sqlite variable.
in fact, the file will be opened at chrome launch, and writed at chrome closure, so less used

the global istringmap initialized at chrome launch, and closed with chrome...

just need to find the right code, as chrome launches several processes (up to 12!!!!!) and not one, if you have ideas to
code some functions to launch *only* once (the first time i click the icon) and close when nom more chrome processes ...

I tried with EnumProcessesEx which work quite good, but is fooled when some the many chrome processes closes, but
some remain....


ended up with this code

Triggered by process "chrome" ended

wait 1
event: 1 started, 2 ended, 4 running
out F"{event} {pid} {name}"
ARRAY(int) allPids
str u="chrome"
_i=ProcessNameToId(u &allPids)
if(allPids.len=0) osd "chrome closed"

if you have more accurate/better coded idea.........
Macro chrome address etc
Trigger !cv"* - Google Chrome" "Chrome_WidgetWin_1" "" "" "" 0x2     Help - how to add the trigger to the macro
Copy      Help
if(getopt(nthreads)>1) ret ;;allow single instance, assuming this is a function or a 'run simultaneously' macro
int hwnd=TriggerWindow ;;if trigger
if(!hwnd) hwnd=win("* - Google Chrome" "Chrome_WidgetWin_1" "" 1) ;;if Run button
if(!hwnd) ret ;;no Chrome
int pid; if(!GetWindowThreadProcessId(hwnd &pid)) end ERR_FAILED 16 ;;hook only this Chrome process
if(!hh) end ERR_FAILED 16
opt waitmsg 1 ;;don't block Windows messages, else sub.Hook cannot be called
wait 0 WP hwnd ;;wait until Chrome process exits
UnhookWinEvent hh

#sub Hook
function hHook event hwnd idObject idChild dwEventThread dwmsEventTime

if(!hwnd) ret
;outw hwnd ;;debug
Acc a.FromEvent(hwnd idObject idChild)
;out a.Name
sel a.Name
,case ["Address and search bar","Barre d'adresse et de recherche"]
,case else ret
str url=a.Value
err+ ;;Acc functions throw error when closing Chrome

out url

Then don't need lock and global variables.
Function triggerd by chrome launched

IStringMap+ m._create

Function triggered when chrome closed

IStringMap+ m
str f

no destructor for IStringMap object????
wonderful, will need some tweaks...
Quote:no destructor for IStringMap object????
IStringMap is a COM interface, QM calls its hidden method Release, and the COM object destroys itself when need.

Forum Jump:

Users browsing this thread: 1 Guest(s)