Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Browser toolbar
#1
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.

TY
Reply
#2
Download
Collected QM apps, functions, samples

Look for
ChangeQmToolbarButtonText
ReplaceToolbarButtonText
Reply
#3
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)??
Reply
#4
Trigger 'window name changed' or an accessible object trigger.
Reply
#5
Tried accessible object trigger with no joy sooo many times..if any example, would be happy
Reply
#6
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
Code:
Select All      Help
;\
function hwnd idObject idChild
Acc a.FromEvent(hwnd idObject idChild)
out a.Value
Reply
#7
hmm, nearly there...works 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

TY
Reply
#8
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
Code:
Select All      Help
;\
function hwnd idObject idChild
Acc a.FromEvent(hwnd idObject idChild)
out a.Value
Reply
#9
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...
Reply
#10
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

URL CUSTOMTEXT

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)
Reply
#11
IStringMap or ICsv.
Use IStringMap if expected large number of items, else both are good. If very very large number, use Sqlite.
Reply
#12
would be <500 items
Reply
#13
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?
Reply
#14
yes, but it's the stringmap -> string procedure i miss

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

M굩o

is météo in the file.

How fix that??
Reply
#18
Open the file in notepad and save as UTF-8.
Or use str.ConvertEncoding.
Reply
#19
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
Reply
#20
setfile creates utf8 file if checked Unicode in Options.
Reply
#21
yes, it is..problem solved..
Reply
#22
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)

lock

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

lock-
Reply
#23
I think 'lock' should be used, as it is in your code, and don't need "only single thread".
Reply
#24
ok, ty
Reply
#25
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.
Reply
#26
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....

EDIT:

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.........
Reply
#27
Macro chrome address etc
Trigger !cv"* - Google Chrome" "Chrome_WidgetWin_1" "" "" "" 0x2     Help - how to add the trigger to the macro
Code:
Select All      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
int hh=SetWinEventHook(EVENT_OBJECT_NAMECHANGE EVENT_OBJECT_NAMECHANGE 0 &sub.Hook pid 0 WINEVENT_OUTOFCONTEXT)
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.
Reply
#28
Function triggerd by chrome launched

IStringMap+ m._create

Function triggered when chrome closed

IStringMap+ m
str f
m.GetList(f)
f.setfile...

no destructor for IStringMap object????
Reply
#29
wonderful, will need some tweaks...
Reply
#30
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)