Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Accessible Object actions in Chrome ver_81x
In Chrome 80x when you executed the following code, the item was automatically selected.  Ex:

Macro Macro102
Copy      Help
int w=wait(3 WV win("Introducing the HTML5 “Menu” and “Menuitem” Elements - Google Chrome" "Chrome_WidgetWin_1"))
Acc a.Find(w "MENUITEM" "Español" "" 0x3001 3)

now in version 81 when you run the code the menu opens, but it is not automatically selected.

Could you tell me if there is any flag in Chrome 81 that can be activated to make the code work, or if not, how to modify the code so that the item is selected automatically.

Attached Files Image(s)
Copy      Help
int w=wait(3 WV win("Introducing the HTML5 “Menu” and “Menuitem” Elements - Google Chrome" "Chrome_WidgetWin_1"))
Acc a.Find(w "STATICTEXT" "Languages:" "" 0x3001 0 0 "next")
Error (RT) in <open ":5032: /171">Macro104:  item not found.    <help #IDP_ERR>?
any other solution (the above doesn't work)?
Somehow object roles sometimes change. Sometimes the combo box is COMBOBOX and item is LISTITEM, and the macro works. Sometimes BUTTONMENU and MENUITEM, and the macro fails. It seems it changes to COMBOBOX when I use the "Find acc object" dialog. The works until restarting Chrome.

This modified CbSelect supports MENUITEM.
Member function Acc.CbSelect2
Copy      Help
function `item [flags] ;;1 always show popup, 2 method2, 4 method3 (Firefox/Chrome), 8 method4

;Selects combo box item.

;item - item text. Exact or with *?. Case insensitive. Or 0-based index.
;;;1 - always show popup list (temporarily).
;;;2 - use different method. Need this for MS Office toolbar comboboxes and some other non-standard comboboxes, especially if editable. Also try flags 2|1.
;;;4 - use different method. Faster. Can be used with Firefox, Chrome and some other windows. Works not with all objects.
;;;8 - use different method with standard combo box. Also you can try flags 8|1.

;This object must have role COMBOBOX. In Chrome also can be BUTTONMENU.
;Works not in all windows.
;If does not work, try various flags and flag combinations, for example 1|2.
;Fast and reliable with:
;;;Standard combo box controls.
;;;Internet Explorer and IE-based web browsers/controls.
;Slower and less reliable with:
;;;Firefox, Chrome.
;;;MS Office dialogs.
;;;MS Office toolbars. Use flag 2. Window must be active.
;;;Java windows. Use flags 2 or 2|1 for editable comboboxes.
;Does not work with:
;;;Windows 7 Wordpad and similar windows.
;In most windows sets focus to the combo box.
;In some windows works only if the window is active. For example Chrome.
;The autodelay (spe) may be applied, depending on browser and flags.

;Errors: ERR_INIT, ERR_ITEM, ERR_FAILED (failed to select).

if(!a) end ERR_INIT

Htm e
int b=__HtmlObj(e)

if b=1 ;;IE
,if flags&1
,,Acc ab.Find(a "PUSHBUTTON") ;;DoDefaultAction and e.Click don't work
,,if(ab.a) ab.DoDefaultAction; ab.DoDefaultAction
,e.CbSelect(item 2)
,err end iif(_error.code=ERRC_ITEM ERR_ITEM ERR_FAILED)

int hc isSimpleCB
isSimpleCB=!b and SendMessage(hc CB_GETITEMHEIGHT -1 0)
if(b=2 and WinTest(hc "Chrome_*")) b=3

if flags&1 and b!3 ;;in Chrome do later, now clears items
,Select(1); err ;;info: it activates window of standard CB. Works without this, but then activates later.
,if(isSimpleCB) SendMessage(hc CB_SHOWDROPDOWN 1 0); if(flags&8=0) SendMessage(hc CB_SHOWDROPDOWN 0 0) ;;info: DoDefaultAction fails
,else DoDefaultAction
else if isSimpleCB and flags&2=0
,SendMessage(GetParent(hc) WM_COMMAND CBN_DROPDOWN<<16|GetWinId(hc) hc) ;;for auto-fill controls

;get list object
Acc ai aList; str role="LISTITEM"
ai.Find(a role "" "" 0x10)
if !ai.a
,ai.Find(a role "" "" 0x10)
if ai.a
,ai.Navigate("pa" aList)
else ;;maybe "list/label" in Java. Or 0 items, or not combobox.
,aList.Find(a "list" "" "" 0x10)
,if(!aList.a) aList=this

sel item.vt
,case VT_I4
,ai.Find(aList.a role "" "" 0x50 0 si.i)
,case VT_BSTR
,ai.Find(aList.a role "" "" 0x50 0 0 "" &sub.Callback &si) ;;info: callback gets item index
,case else end ERR_BADARG
if(!ai.a) end ERR_ITEM

if isSimpleCB and flags&8=0
,CB_SelectItem hc si.i-1

if(flags&4) ai.DoDefaultAction; ret

if flags&1
,if b=3
,,Select(1); err
,,DoDefaultAction ;;tested: Chrome sometimes changes STATE_SYSTEM_COLLAPSED, sometimes not
,Select(1); err
,if(flags&2=0 and !b) DoDefaultAction; err flags|2 ;;show popup list. In Office would defocus instead.

if(flags&2=0) sub.PostKey hc VK_HOME; else rep(aList.ChildCount) sub.PostKey hc VK_UP ;;Home does not work in Office toolbars
rep(si.i-1) sub.PostKey hc VK_DOWN

;need Enter to close popup (flag 1) or submit
if flags&1=0 and !isSimpleCB
,if(b!3) flags|1 ;;in Chrome Enter shows CB list
if flags&1
,if(b=3) 0.1 ;;in Chrome async, may not close if too early
,sub.PostKey hc VK_RETURN

rep(2) SendMessage hc 0 0 0; 0.01
wait -2

err+ end ERR_FAILED

#sub Callback
function# Acc&ai level STRINT&r

str s=ai.Name
if(!s.len and r.s.len) s=ai.Value ;;Chrome
ret !matchw(s r.s 1)
err ret 1

#sub PostKey
function h vk
PostMessage h WM_KEYDOWN vk 0
PostMessage h WM_KEYUP vk 0
;tested: SendMessage does not work. PostMessage works better than key.

;ai.DoDefaultAction etc don't work. In FF selects, but does notify FF; then keyboard navigation does not work.
;In windows other than IE/FF/Chrome/simpleCB:
;;;In most windows works well only with popup list (this.DoDefaultAction).
;In FF could post first char several times. Faster but not reliable. Or could post PageDown, but difficult.

;For listboxes:
;With simple listbox and IE, can use Select().
;In Firefox Select() does not work. To select single item, can use DoDefaultAction or this func.
It works OK. Thank you.
One more thing, in Chrome 80, Macro102 worked ok: do you know what was the change they made in Chrome 81?

Forum Jump:

Users browsing this thread: 1 Guest(s)