Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Wait in Firefox and Chrome
#8
I was surprised this morning to discover that Google Chrome reload button acc.Description is now empty. I am wondering about the way one could then detect the busy state. One idea that I have at this moment is to use scan to detect the button's image (stop or reload image). Any advice will be most welcome.

Thanks in advance

PS : I attach herewith a version of my new wait for chrome routine, which it works satisfactorily. I will be pleased to answer any inquiries.

Function ChromeWait
Code:
Copy      Help
;/
function# [$url]

str si.getmacro(getopt(itemid) 1)
str caller.getmacro(getopt(itemid 1) 1);err    caller=si
if ideb; min 0; err out "<>%s : <open ''%s /%i''>%s</open> - Called by : %s" NowT si _error.place si caller

int w=win("New Tab - Google Chrome" "Chrome_WidgetWin_1")



;---> Comment 21-05-2015 10:25:43 : Changes in GC
;a1.Description is now Empty !

;Waits while Chrome is busy (loading page).
;Returns window handle.
;Error if fails, eg if Chrome closed while waiting.
;Tested with Google Chrome 7.0 and 21.0. May not work with other versions.

;url - web page address to open.
;;;If empty, just waits while Chrome is busy.
;;;Can include command line, eg "--disable-extensions ''url''".

;May not wait if this function opens new window when a window already exists.
;Does not work if toolbar or its Reload button does not exist.

;To get "busy" state, uses accessible object properties of main toolbar and its Reload button.
;If your Chrome uses language other than English, the default values may not match. Then the function fails (error). Open this function and change variables. You can discover the values using the 'Find Accessible Object' dialog.


;variables to change. Usually only the last two.
;str toolbarName="Chrome" ;;can be partial
str buttonName="Reload" ;;can be partial
str buttonDescriptionBeginsWith="Reload" ;;begins with

;____________________________________________

int w1=WB_Open("chrome" url "Chrome" "Chrome_WidgetWin_*" 0x804)

;http://www.quickmacros.com/forum/viewtopic.php?p=20595

;---> Comment 13-03-2015 11:15:05 : toolbarName changed from "Chrome" to "main"
str toolbarName="main" ;;can be partial


;
;get toolbar acc
Acc a=acc(toolbarName "TOOLBAR" w1 "" "" 0x1010 0 0 "" 30)
;get Reload button acc
err
,_s=_error.description
,out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s
,mac "Warning_QM" si
,end

a=acc(buttonName "PUSHBUTTON" a "" "" 16)
err
,_s=_error.description
,out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s
,mac "Warning_QM" si
,end

int x y cx cy
a.Location(x y cx cy)
;out F"{x} {y} {x+cx} {y+cy} "

str scr=F"C:\Documents and Settings\S.E.Simopoulos\My QM\bmp\GC_Reload_{uSN}.bmp"
if !scr.FileExistS
,_s=F"Scan File does not exist : {scr}  - Caller : <open>{caller}</open>"
,min 0; err out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s
,mac "Warning_QM" si 0
,end

RECT r

int n

mac "ChromeWait_TrayInd"

opt waitmsg -1
int waitmax=60
int wt(waitmax*1000) t1(GetTickCount)
rep
,0.1
,r.left=x; r.top=y; r.right=x+cx; r.bottom=y+cy
,int i=scan(scr 0 r 0 10)
,if i
,,n+1
,,;_s.format("%i" n)
,,;min 0; err out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s
,,if(n=10) break
,else
,,n=0

,if(wt>0 and GetTickCount-t1>=wt)
,,_s=F"Wait Timeout - Caller : <open>{caller}</open>"
,,min 0; err out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s
,,mac "Warning_QM" si 0
,,shutdown -6 0 "ChromeWait_TrayInd"
,,end

shutdown -6 0 "ChromeWait_TrayInd"
ret w1
err+ end ES_FAILED

;info: Chrome 7.0 toolbar buttons are not customizable.


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)