• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# AccessibilityExtensionContext (辅助功能扩展上下文)
2
3AccessibilityExtensionContext是AccessibilityExtensionAbility上下文环境,继承自ExtensionContext。
4
5辅助功能扩展上下文模块提供辅助功能扩展的上下文环境的能力,包括允许配置辅助应用关注信息类型、查询节点信息、手势注入等。
6
7> **说明:**
8>
9> - 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
10
11## 使用说明
12
13在使用AccessibilityExtensionContext的功能前,需要通过AccessibilityExtensionAbility子类实例获取AccessibilityExtensionContext的实例。
14
15```ts
16import { AccessibilityExtensionAbility } from '@kit.AccessibilityKit';
17
18class EntryAbility extends AccessibilityExtensionAbility {
19  onConnect(): void {
20    let axContext = this.context;
21  }
22}
23```
24
25## ElementAttributeValues
26
27节点元素具备的属性名称及属性值类型信息。
28
29**系统能力**:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Core
30
31### 属性
32
33| 名称                   | 类型                                                                 | 可读  | 可写  | 说明                  |
34|----------------------|--------------------------------------------------------------------|-----|-----| ------------------- |
35| accessibilityFocused | boolean                                                            | 是   | 否   |   accessibility焦点状态。   |
36| accessibilityText<sup>12+</sup> | string                                                  | 是   | 否   | 元素的无障碍文本信息。 |
37| bundleName           | string                                                             | 是   | 否   | 应用包名。 |
38| checkable            | boolean                                                            | 是   | 否   | 元素是否可查。 |
39| checked              | boolean                                                            | 是   | 否   | 元素是否被检查。 |
40| children             | Array&lt;[AccessibilityElement](#accessibilityelement9)&gt;        | 是   | 否   | 所有子元素。 |
41| clickable            | boolean                                                            | 是   | 否   | 是否可点击。 |
42| componentId          | number                                                             | 是   | 否   | 元素所属的组件ID。 |
43| componentType        | string                                                             | 是   | 否   | 元素所属的组件类型。 |
44| contents             | Array&lt;string&gt;                                                | 是   | 否   | 内容。 |
45| currentIndex         | number                                                             | 是   | 否   | 当前项的索引。 |
46| description          | string                                                             | 是   | 否   | 元素的描述信息。 |
47| editable             | boolean                                                            | 是   | 否   | 元素是否可编辑。 |
48| endIndex             | number                                                             | 是   | 否   | 屏幕最后显示项的列表索引。 |
49| error                | string                                                             | 是   | 否   | 错误状态字符串。 |
50| focusable            | boolean                                                            | 是   | 否   | 元素是否可聚焦。 |
51| hintText             | string                                                             | 是   | 否   | 提示文本。 |
52| inputType            | number                                                             | 是   | 否   | 输入文本的类型。 |
53| inspectorKey         | string                                                             | 是   | 否   | 检查键。 |
54| isActive             | boolean                                                            | 是   | 否   | 元素是否处于活动状态。 |
55| isEnable             | boolean                                                            | 是   | 否   | 元素是否启用。 |
56| isHint               | boolean                                                            | 是   | 否   | 元素是否为提示状态。 |
57| isFocused            | boolean                                                            | 是   | 否   | 元素是否聚焦。 |
58| isPassword           | boolean                                                            | 是   | 否   | 元素是否为密码。 |
59| isVisible            | boolean                                                            | 是   | 否   | 元素是否可见。 |
60| itemCount            | number                                                             | 是   | 否   | 项目的总数。 |
61| lastContent          | string                                                             | 是   | 否   | 最后的内容。 |
62| layer                | number                                                             | 是   | 否   | 该元素的显示层。 |
63| longClickable        | boolean                                                            | 是   | 否   | 元素是否可长单击。 |
64| pageId               | number                                                             | 是   | 否   | 页码id。 |
65| parent               | [AccessibilityElement](#accessibilityelement9)                     | 是   | 否   | 元素的父元素。 |
66| pluralLineSupported  | boolean                                                            | 是   | 否   | 元素是否支持多行文本。 |
67| rect                 | [Rect](#rect)                                                      | 是   | 否   | 元素的面积。 |
68| resourceName         | string                                                             | 是   | 否   | 元素的资源名称。 |
69| rootElement          | [AccessibilityElement](#accessibilityelement9)                     | 是   | 否   | 窗口元素的根元素。 |
70| screenRect           | [Rect](#rect)                                                      | 是   | 否   | 元素的显示区域。 |
71| scrollable           | boolean                                                            | 是   | 否   | 元素是否可滚动。 |
72| selected             | boolean                                                            | 是   | 否   | 元素是否被选中。 |
73| startIndex           | number                                                             | 是   | 否   | 在屏幕上的第一个项目的列表索引。 |
74| text                 | string                                                             | 是   | 否   | 元素的文本。 |
75| textLengthLimit      | number                                                             | 是   | 否   | 元素文本的最大长度限制。 |
76| textMoveUnit         | [accessibility.TextMoveUnit](js-apis-accessibility.md#textmoveunit) | 是   | 否   | 文本被读取时的移动单位。 |
77| triggerAction        | [accessibility.Action](js-apis-accessibility.md#action)         | 是   | 否   | 触发元素事件的动作。 |
78| type                 | [WindowType](#windowtype)                                          | 是   | 否   | 元素的窗口类型。 |
79| valueMax             | number                                                             | 是   | 否   | 最大值。 |
80| valueMin             | number                                                             | 是   | 否   | 最小值。|
81| valueNow             | number                                                             | 是   | 否   | 当前值。 |
82| windowId             | number                                                             | 是   | 否   | 窗口id。 |
83| textType<sup>12+</sup>             | string                                                             | 是   | 否   | 元素的无障碍文本类型,由组件accessibilityTextHint属性配置。 |
84| offset<sup>12+</sup>             | number                                                             | 是   | 否   | 对于可滚动类控件,如List、Grid,内容区相对控件的顶部坐标滚动的像素偏移量。 |
85| hotArea<sup>12+</sup>             | [Rect](#rect)                                                              | 是   | 否   | 元素的可触摸区域。 |
86| customComponentType<sup>18+</sup>             | string                                                             | 是   | 否   | 自定义组件类型。 |
87| accessibilityNextFocusId<sup>18+</sup>             | number                | 是   | 否   | 下一个要聚焦的组件ID。通过findElement('elementId')查询到的AccessibilityElementInfo对象中可获取到用户在控件上设置的该属性值。 |
88| accessibilityPreviousFocusId<sup>18+</sup>             | number                | 是   | 否   | 上一个聚焦的组件ID。通过findElement('elementId')查询到的AccessibilityElementInfo对象中可获取到用户在控件上设置的该属性值。 |
89| extraInfo<sup>18+</sup>             | string   | 是   | 否   | 扩展属性,用于定义一些特定组件的属性,包含:<br>- CheckboxGroupSelectedStatus:表示CheckboxGroup组件的选中状态,其中取值0表示已选中,取值1表示部分选中,取值2表示未选中。<br>- Row:Grid组件中聚焦item的行信息,表示该item在第几行。<br>- Column:Column:Grid组件中聚焦的item的列,表示该item在第几列。<br>- ListItemIndex:表示List组件中聚焦的item的行。<br>- SideBarContainerStates:表示可展开类组件(SideBarContainer、Select)的展开状态,其中取值0表示收起态,取值1表示展开态。<br>- ToggleType:表示Toggle组件的具体类型,其中取值0表示Checkbox,取值1表示Switch,取值2表示Button。<br>- BindSheet:表示BindSheet组件的状态,其中取值0表示状态高,取值1表示状态中,取值2表示状态低。<br>- hasRegisteredHover:表示组件是否注册了onAccessibilityHover事件回调,取值为1表示组件注册了事件回调,若未注册不会使用该字段。<br>- direction:表示list组件布局方向,其中取值"vertical"表示竖向,取值"horizontal"表示横向。<br>- expandedState:表示list组件中listItem的展开状态,其中取值"expanded"表示展开态,取值"collapsed"表示收起态。|
90| accessibilityScrollable<sup>18+</sup>             | boolean                 | 是   | 否   | 无障碍模式下元素是否滚动,优先级高于scrollable。其中,true表示可滚动,false表示不可滚动,默认值为true。|
91
92## FocusDirection
93
94type FocusDirection = 'up' | 'down' | 'left' | 'right' | 'forward' | 'backward'
95
96表示查询下一焦点元素的方向。
97
98**系统能力**:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Core
99
100| 类型       | 说明      |
101| -------- | ------- |
102| 'up'       | 表示向上查询。 |
103| 'down'     | 表示向下查询。 |
104| 'left'     | 表示向左查询。 |
105| 'right'    | 表示向右查询。 |
106| 'forward'  | 表示向前查询。 |
107| 'backward' | 表示向后查询。 |
108
109## FocusType
110
111type FocusType = 'accessibility' | 'normal'
112
113表示查询焦点元素的类型。
114
115**系统能力**:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Core
116
117| 类型            | 说明          |
118| ------------- | ----------- |
119| 'accessibility' | 表示无障碍的焦点类型。 |
120| 'normal'        | 表示普通的焦点类型。  |
121
122## Rect
123
124表示矩形区域。
125
126**系统能力**:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Core
127
128| 名称     | 类型     | 可读   | 可写   | 说明        |
129| ------ | ------ | ---- | ---- | --------- |
130| left   | number | 是    | 否    | 矩形区域的左边界。 |
131| top    | number | 是    | 否    | 矩形区域的上边界。 |
132| width  | number | 是    | 否    | 矩形区域的宽度。  |
133| height | number | 是    | 否    | 矩形区域的高度。  |
134
135## WindowType
136
137type WindowType = 'application' | 'system'
138
139表示窗口的类型。
140
141**系统能力**:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Core
142
143| 类型          | 说明        |
144| ----------- | --------- |
145| 'application' | 表示应用窗口类型。 |
146| 'system'      | 表示系统窗口类型。 |
147
148## AccessibilityExtensionContext.setTargetBundleName<sup>(deprecated)</sup>
149
150setTargetBundleName(targetNames: Array\<string>): Promise\<void>;
151
152设置关注的目标包名,使用Promise异步回调。
153
154> **说明:**
155>
156> 从API version 12开始废弃。
157
158**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
159
160**参数:**
161
162| 参数名         | 类型                  | 必填   | 说明       |
163| ----------- | ------------------- | ---- | -------- |
164| targetNames | Array&lt;string&gt; | 是    | 设置关注应用的包名,服务接收关注应用的无障碍事件,默认接收所有应用的无障碍事件,取消关注应用则传空数组。 |
165
166**返回值:**
167
168| 类型                  | 说明               |
169| ------------------- | ---------------- |
170| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
171
172**错误码:**
173
174以下错误码的详细介绍请参见[无障碍子系统错误码](errorcode-accessibility.md)。
175
176| 错误码ID | 错误信息 |
177| ------- | -------------------------------- |
178| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
179
180**示例:**
181
182```ts
183import { BusinessError } from '@kit.BasicServicesKit';
184
185let targetNames = ['com.ohos.xyz'];
186axContext.setTargetBundleName(targetNames).then(() => {
187  console.info(`Succeeded in set target bundle names, targetNames is ${targetNames}`);
188}).catch((err: BusinessError) => {
189  console.error(`failed to set target bundle names, Code is ${err.code}, message is ${err.message}`);
190})
191```
192
193## AccessibilityExtensionContext.setTargetBundleName<sup>(deprecated)</sup>
194
195setTargetBundleName(targetNames: Array\<string>, callback: AsyncCallback\<void>): void;
196
197设置关注的目标包名,使用callback异步回调。
198
199> **说明:**
200>
201> 从API version 12开始废弃。
202
203**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
204
205**参数:**
206
207| 参数名         | 类型                        | 必填   | 说明                                       |
208| ----------- | ------------------------- | ---- | ---------------------------------------- |
209| targetNames | Array&lt;string&gt;       | 是    | 设置关注应用的包名,服务接收关注应用的无障碍事件,默认接收所有应用的无障碍事件,取消关注应用则传空数组。                                 |
210| callback    | AsyncCallback&lt;void&gt; | 是    | 回调函数,如果设置关注的目标包名失败,则AsyncCallback中err有数据返回。 |
211
212**错误码:**
213
214以下错误码的详细介绍请参见[无障碍子系统错误码](errorcode-accessibility.md)。
215
216| 错误码ID | 错误信息 |
217| ------- | -------------------------------- |
218| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
219
220**示例:**
221
222```ts
223import { BusinessError } from '@kit.BasicServicesKit';
224
225let targetNames = ['com.ohos.xyz'];
226try {
227  axContext.setTargetBundleName(targetNames, (err: BusinessError) => {
228    if (err && err.code) {
229      console.error(`failed to set target bundle names, Code is ${err.code}, message is ${err.message}`);
230      return;
231    }
232    console.info(`Succeeded in set target bundle names, targetNames is ${targetNames}`);
233  });
234} catch (error) {
235  console.error(`failed to set target bundle names, Because ${JSON.stringify(error)}`);
236}
237```
238
239## AccessibilityExtensionContext.getFocusElement<sup>(deprecated)</sup>
240
241getFocusElement(isAccessibilityFocus?: boolean): Promise\<AccessibilityElement>;
242
243获取焦点元素, 使用Promise异步回调。
244
245> **说明:**
246>
247> 从API version 12开始废弃。
248
249**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
250
251**参数:**
252
253| 参数名                  | 类型      | 必填   | 说明                  |
254| -------------------- | ------- | ---- | ------------------- |
255| isAccessibilityFocus | boolean | 否    | 获取的是否是无障碍焦点元素,True表示是,False表示否,默认为否。 |
256
257**返回值:**
258| 类型                                  | 说明                     |
259| ----------------------------------- | ---------------------- |
260| Promise&lt;[AccessibilityElement](#accessibilityelement9)&gt; | Promise对象,返回当前对应的焦点元素。 |
261
262**错误码:**
263
264以下错误码的详细介绍请参见[无障碍子系统错误码](errorcode-accessibility.md)。
265
266| 错误码ID   | 错误信息                                     |
267| ------- | ---------------------------------------- |
268| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
269| 9300003 | No accessibility permission to perform the operation. |
270
271**示例:**
272
273```ts
274import { AccessibilityElement } from '@kit.AccessibilityKit';
275import { BusinessError } from '@kit.BasicServicesKit';
276
277let rootElement: AccessibilityElement;
278
279axContext.getFocusElement().then((data: AccessibilityElement) => {
280  rootElement = data;
281  console.log(`Succeeded in get focus element,${JSON.stringify(data)}`);
282}).catch((err: BusinessError) => {
283  console.error(`failed to get focus element, Code is ${err.code}, message is ${err.message}`);
284})
285```
286
287## AccessibilityExtensionContext.getFocusElement<sup>(deprecated)</sup>
288
289getFocusElement(callback: AsyncCallback\<AccessibilityElement>): void;
290
291获取焦点元素, 使用callback异步回调。
292
293> **说明:**
294>
295> 从API version 12开始废弃。
296
297**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
298
299**参数:**
300
301| 参数名      | 类型                                       | 必填   | 说明                |
302| -------- | ---------------------------------------- | ---- | ----------------- |
303| callback | AsyncCallback&lt;[AccessibilityElement](#accessibilityelement9)&gt; | 是    | 回调函数,返回当前对应的焦点元素。 |
304
305**错误码:**
306
307以下错误码的详细介绍请参见[无障碍子系统错误码](errorcode-accessibility.md)。
308
309| 错误码ID   | 错误信息                                     |
310| ------- | ---------------------------------------- |
311| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
312| 9300003 | No accessibility permission to perform the operation. |
313
314**示例:**
315
316```ts
317import { AccessibilityElement } from '@kit.AccessibilityKit';
318import { BusinessError } from '@kit.BasicServicesKit';
319
320let rootElement: AccessibilityElement;
321
322axContext.getFocusElement((err: BusinessError, data: AccessibilityElement) => {
323  if (err && err.code) {
324    console.error(`failed to get focus element, Code is ${err.code}, message is ${err.message}`);
325    return;
326  }
327  rootElement = data;
328  console.info(`Succeeded in get focus element, ${JSON.stringify(data)}`);
329});
330```
331
332## AccessibilityExtensionContext.getFocusElement<sup>(deprecated)</sup>
333
334getFocusElement(isAccessibilityFocus: boolean, callback: AsyncCallback\<AccessibilityElement>): void;
335
336获取焦点元素, 使用callback异步回调。
337
338> **说明:**
339>
340> 从API version 12开始废弃。
341
342**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
343
344**参数:**
345
346| 参数名                  | 类型                                       | 必填   | 说明                |
347| -------------------- | ---------------------------------------- | ---- | ----------------- |
348| isAccessibilityFocus | boolean                                  | 是    | 获取的是否是无障碍焦点元素,True表示是,False表示否。    |
349| callback             | AsyncCallback&lt;[AccessibilityElement](#accessibilityelement9)&gt; | 是    | 回调函数,返回当前对应的焦点元素。 |
350
351**错误码:**
352
353以下错误码的详细介绍请参见[无障碍子系统错误码](errorcode-accessibility.md)。
354
355| 错误码ID   | 错误信息                                     |
356| ------- | ---------------------------------------- |
357| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
358| 9300003 | No accessibility permission to perform the operation. |
359
360**示例:**
361
362```ts
363import { AccessibilityElement } from '@kit.AccessibilityKit';
364import { BusinessError } from '@kit.BasicServicesKit';
365
366let isAccessibilityFocus = true;
367let rootElement: AccessibilityElement;
368
369axContext.getFocusElement(isAccessibilityFocus, (err: BusinessError, data: AccessibilityElement)=> {
370  if (err && err.code) {
371    console.error(`failed to get focus element, Code is ${err.code}, message is ${err.message}`);
372    return;
373  }
374  rootElement = data;
375  console.info(`Succeeded in get focus element, ${JSON.stringify(data)}`);
376});
377```
378
379## AccessibilityExtensionContext.getWindowRootElement<sup>(deprecated)</sup>
380
381getWindowRootElement(windowId?: number): Promise\<AccessibilityElement>;
382
383获取指定窗口的根节点元素, 使用Promise异步回调。
384
385> **说明:**
386>
387> 从API version 12开始废弃。
388
389**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
390
391**参数:**
392
393| 参数名      | 类型     | 必填   | 说明                     |
394| -------- | ------ | ---- | ---------------------- |
395| windowId | number | 否    | 指定窗口的编号,未指定则从当前活跃窗口获取。 |
396
397**返回值:**
398
399| 类型                                  | 说明                     |
400| ----------------------------------- | ---------------------- |
401| Promise&lt;[AccessibilityElement](#accessibilityelement9)&gt; | Promise对象,返回指定窗口的根节点元素。 |
402
403**错误码:**
404
405以下错误码的详细介绍请参见[无障碍子系统错误码](errorcode-accessibility.md)。
406
407| 错误码ID   | 错误信息                                     |
408| ------- | ---------------------------------------- |
409| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
410| 9300003 | No accessibility permission to perform the operation. |
411
412**示例:**
413
414```ts
415import { AccessibilityElement } from '@kit.AccessibilityKit';
416import { BusinessError } from '@kit.BasicServicesKit';
417
418let rootElement: AccessibilityElement;
419
420axContext.getWindowRootElement().then((data: AccessibilityElement) => {
421  rootElement = data;
422  console.log(`Succeeded in get root element of the window, ${JSON.stringify(data)}`);
423}).catch((err: BusinessError) => {
424  console.error(`failed to get root element of the window, Code is ${err.code}, message is ${err.message}`);
425});
426```
427
428## AccessibilityExtensionContext.getWindowRootElement<sup>(deprecated)</sup>
429
430getWindowRootElement(callback: AsyncCallback\<AccessibilityElement>): void;
431
432获取指定窗口的根节点元素, 使用callback异步回调。
433
434> **说明:**
435>
436> 从API version 12开始废弃。
437
438**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
439
440**参数:**
441
442| 参数名      | 类型                                       | 必填   | 说明                 |
443| -------- | ---------------------------------------- | ---- | ------------------ |
444| callback | AsyncCallback&lt;[AccessibilityElement](#accessibilityelement9)&gt; | 是    | 回调函数,返回指定窗口的根节点元素。 |
445
446**错误码:**
447
448以下错误码的详细介绍请参见[无障碍子系统错误码](errorcode-accessibility.md)。
449
450| 错误码ID   | 错误信息                                     |
451| ------- | ---------------------------------------- |
452| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
453| 9300003 | No accessibility permission to perform the operation. |
454
455**示例:**
456
457```ts
458import { AccessibilityElement } from '@kit.AccessibilityKit';
459import { BusinessError } from '@kit.BasicServicesKit';
460
461let rootElement: AccessibilityElement;
462
463axContext.getWindowRootElement((err: BusinessError, data: AccessibilityElement) => {
464  if (err && err.code) {
465    console.error(`failed to get root element of the window, Code is ${err.code}, message is ${err.message}`);
466    return;
467  }
468  rootElement = data;
469  console.info(`Succeeded in get root element of the window, ${JSON.stringify(data)}`);
470});
471```
472
473## AccessibilityExtensionContext.getWindowRootElement<sup>(deprecated)</sup>
474
475getWindowRootElement(windowId: number, callback: AsyncCallback\<AccessibilityElement>): void;
476
477获取指定窗口的根节点元素, 使用callback异步回调。
478
479> **说明:**
480>
481> 从API version 12开始废弃。
482
483**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
484
485**参数:**
486
487| 参数名      | 类型                                       | 必填   | 说明                     |
488| -------- | ---------------------------------------- | ---- | ---------------------- |
489| windowId | number                                   | 是    | 指定窗口的编号,未指定则从当前活跃窗口获取。 |
490| callback | AsyncCallback&lt;[AccessibilityElement](#accessibilityelement9)&gt; | 是    | 回调函数,返回指定窗口的根节点元素。     |
491
492**错误码:**
493
494以下错误码的详细介绍请参见[无障碍子系统错误码](errorcode-accessibility.md)。
495
496| 错误码ID   | 错误信息                                     |
497| ------- | ---------------------------------------- |
498| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
499| 9300003 | No accessibility permission to perform the operation. |
500
501**示例:**
502
503```ts
504import { AccessibilityElement } from '@kit.AccessibilityKit';
505import { BusinessError } from '@kit.BasicServicesKit';
506
507let windowId = 10;
508let rootElement: AccessibilityElement;
509
510axContext.getWindowRootElement(windowId, (err: BusinessError, data: AccessibilityElement) => {
511  if (err && err.code) {
512    console.error(`failed to get root element of the window, Code is ${err.code}, message is ${err.message}`);
513    return;
514  }
515  rootElement = data;
516  console.info(`Succeeded in get root element of the window, ${JSON.stringify(data)}`);
517});
518```
519
520## AccessibilityExtensionContext.getWindows<sup>(deprecated)</sup>
521
522getWindows(displayId?: number): Promise\<Array\<AccessibilityElement>>;
523
524获取指定屏幕中的所有窗口, 使用Promise异步回调。
525
526> **说明:**
527>
528> 从API version 12开始废弃。
529
530**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
531
532**参数:**
533
534| 参数名       | 类型     | 必填   | 说明                    |
535| --------- | ------ | ---- | --------------------- |
536| displayId | number | 否    | 指定的屏幕编号,未指定则从默认主屏幕获取。 |
537
538**返回值:**
539
540| 类型                                       | 说明                     |
541| ---------------------------------------- | ---------------------- |
542| Promise&lt;Array&lt;[AccessibilityElement](#accessibilityelement9)&gt;&gt; | Promise对象,返回指定屏幕的所有窗口。 |
543
544**错误码:**
545
546以下错误码的详细介绍请参见[无障碍子系统错误码](errorcode-accessibility.md)。
547
548| 错误码ID   | 错误信息                                     |
549| ------- | ---------------------------------------- |
550| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
551| 9300003 | No accessibility permission to perform the operation. |
552
553**示例:**
554
555```ts
556import { AccessibilityElement } from '@kit.AccessibilityKit';
557import { BusinessError } from '@kit.BasicServicesKit';
558
559axContext.getWindows().then((data: AccessibilityElement[]) => {
560  console.log(`Succeeded in get windows, ${JSON.stringify(data)}`);
561}).catch((err: BusinessError) => {
562  console.error(`failed to get windows, Code is ${err.code}, message is ${err.message}`);
563});
564```
565
566## AccessibilityExtensionContext.getWindows<sup>(deprecated)</sup>
567
568getWindows(callback: AsyncCallback\<Array\<AccessibilityElement>>): void;
569
570获取指定屏幕中的所有窗口, 使用callback异步回调。
571
572> **说明:**
573>
574> 从API version 12开始废弃。
575
576**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
577
578**参数:**
579
580| 参数名      | 类型                                       | 必填   | 说明                |
581| -------- | ---------------------------------------- | ---- | ----------------- |
582| callback | AsyncCallback&lt;Array&lt;[AccessibilityElement](#accessibilityelement9)&gt;&gt; | 是    | 回调函数,返回指定屏幕的所有窗口。 |
583
584**错误码:**
585
586以下错误码的详细介绍请参见[无障碍子系统错误码](errorcode-accessibility.md)。
587
588| 错误码ID   | 错误信息                                     |
589| ------- | ---------------------------------------- |
590| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
591| 9300003 | No accessibility permission to perform the operation. |
592
593**示例:**
594
595```ts
596import { AccessibilityElement } from '@kit.AccessibilityKit';
597import { BusinessError } from '@kit.BasicServicesKit';
598
599axContext.getWindows((err: BusinessError, data: AccessibilityElement[]) => {
600  if (err && err.code) {
601    console.error(`failed to get windows, Code is ${err.code}, message is ${err.message}`);
602    return;
603  }
604  console.info(`Succeeded in get windows, ${JSON.stringify(data)}`);
605});
606```
607
608## AccessibilityExtensionContext.getWindows<sup>(deprecated)</sup>
609
610getWindows(displayId: number, callback: AsyncCallback\<Array\<AccessibilityElement>>): void;
611
612获取指定屏幕中的所有窗口, 使用callback异步回调。
613
614> **说明:**
615>
616> 从API version 12开始废弃。
617
618**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
619
620**参数:**
621
622| 参数名       | 类型                                       | 必填   | 说明                    |
623| --------- | ---------------------------------------- | ---- | --------------------- |
624| displayId | number                                   | 是    | 指定的屏幕编号,未指定则从默认主屏幕获取。 |
625| callback  | AsyncCallback&lt;Array&lt;[AccessibilityElement](#accessibilityelement9)&gt;&gt; | 是    | 回调函数,返回指定屏幕的所有窗口。     |
626
627**错误码:**
628
629以下错误码的详细介绍请参见[无障碍子系统错误码](errorcode-accessibility.md)。
630
631| 错误码ID   | 错误信息                                     |
632| ------- | ---------------------------------------- |
633| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
634| 9300003 | No accessibility permission to perform the operation. |
635
636**示例:**
637
638```ts
639import { AccessibilityElement } from '@kit.AccessibilityKit';
640import { BusinessError } from '@kit.BasicServicesKit';
641
642let displayId = 10;
643axContext.getWindows(displayId, (err: BusinessError, data: AccessibilityElement[]) => {
644  if (err && err.code) {
645    console.error(`failed to get windows, Code is ${err.code}, message is ${err.message}`);
646    return;
647  }
648  console.info(`Succeeded in get windows, ${JSON.stringify(data)}`);
649});
650```
651
652## AccessibilityExtensionContext.injectGesture<sup>(deprecated)</sup>
653
654injectGesture(gesturePath: GesturePath): Promise\<void>;
655
656> **说明:**
657>
658> 从API version 10开始废弃。
659
660注入手势,使用Promise异步回调。
661
662**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
663
664**参数:**
665
666| 参数名         | 类型                                                                 | 必填   | 说明         |
667| ----------- |--------------------------------------------------------------------| ---- | ---------- |
668| gesturePath | [GesturePath](js-apis-accessibility-GesturePath.md#gesturepath) | 是    | 表示手势的路径信息。 |
669
670**返回值:**
671
672| 类型                  | 说明               |
673| ------------------- | ---------------- |
674| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
675
676**错误码:**
677
678以下错误码的详细介绍请参见[无障碍子系统错误码](errorcode-accessibility.md)。
679
680| 错误码ID   | 错误信息                                     |
681| ------- | ---------------------------------------- |
682| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
683| 9300003 | No accessibility permission to perform the operation. |
684
685**示例:**
686
687```ts
688import { GesturePath, GesturePoint } from '@kit.AccessibilityKit';
689import { BusinessError } from '@kit.BasicServicesKit';
690
691let gesturePath: GesturePath = new GesturePath(100);
692
693for (let i = 0; i < 10; i++) {
694  let gesturePoint = new GesturePoint(100, i * 200);
695  gesturePath.points.push(gesturePoint);
696}
697axContext.injectGesture(gesturePath).then(() => {
698  console.info(`Succeeded in inject gesture,gesturePath is ${gesturePath}`);
699}).catch((err: BusinessError) => {
700  console.error(`failed to inject gesture, Code is ${err.code}, message is ${err.message}`);
701});
702```
703## AccessibilityExtensionContext.injectGesture<sup>(deprecated)</sup>
704
705injectGesture(gesturePath: GesturePath, callback: AsyncCallback\<void>): void
706
707> **说明:**
708>
709> 从API version 10开始废弃。
710
711注入手势,使用callback异步回调。
712
713**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
714
715**参数:**
716
717| 参数名         | 类型                                                                 | 必填   | 说明                  |
718| ----------- |--------------------------------------------------------------------| ---- | ------------------- |
719| gesturePath | [GesturePath](js-apis-accessibility-GesturePath.md#gesturepath) | 是    | 表示手势的路径信息。          |
720| callback    | AsyncCallback&lt;void&gt;                                          | 是    | 回调函数,表示注入手势执行结果的回调。 |
721
722**错误码:**
723
724以下错误码的详细介绍请参见[无障碍子系统错误码](errorcode-accessibility.md)。
725
726| 错误码ID   | 错误信息                                     |
727| ------- | ---------------------------------------- |
728| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
729| 9300003 | No accessibility permission to perform the operation. |
730
731**示例:**
732
733```ts
734import { GesturePath, GesturePoint } from '@kit.AccessibilityKit';
735import { BusinessError } from '@kit.BasicServicesKit';
736
737let gesturePath: GesturePath = new GesturePath(100);
738for (let i = 0; i < 10; i++) {
739  let gesturePoint = new GesturePoint(100, i * 200);
740  gesturePath.points.push(gesturePoint);
741}
742axContext.injectGesture(gesturePath, (err: BusinessError) => {
743  if (err) {
744    console.error(`failed to inject gesture, Code is ${err.code}, message is ${err.message}`);
745    return;
746  }
747  console.info(`Succeeded in inject gesture,gesturePath is ${gesturePath}`);
748});
749```
750## AccessibilityExtensionContext.injectGestureSync<sup>(deprecated)</sup>
751
752injectGestureSync(gesturePath: GesturePath): void
753
754注入手势。
755
756> **说明:**
757>
758> 从API version 12开始废弃。
759
760**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
761
762**参数:**
763
764| 参数名      | 类型                                                                 | 必填 | 说明                 |
765| ----------- |--------------------------------------------------------------------| ---- | -------------------- |
766| gesturePath | [GesturePath](js-apis-accessibility-GesturePath.md#gesturepath) | 是   | 表示手势的路径信息。 |
767
768**错误码:**
769
770以下错误码的详细介绍请参见[无障碍子系统错误码](errorcode-accessibility.md)。
771
772| 错误码ID | 错误信息                                            |
773| -------- | --------------------------------------------------- |
774| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
775| 9300003  | No accessibility permission to perform the operation. |
776
777**示例:**
778
779```ts
780import { GesturePath, GesturePoint } from '@kit.AccessibilityKit';
781
782let gesturePath: GesturePath = new GesturePath(100);
783for (let i = 0; i < 10; i++) {
784  let gesturePoint = new GesturePoint(100, i * 200);
785  gesturePath.points.push(gesturePoint);
786}
787axContext.injectGestureSync(gesturePath);
788```
789
790## AccessibilityElement<sup>9+</sup>
791
792无障碍节点元素, 在调用AccessibilityElement的方法前,需要先通过[AccessibilityExtensionContext.getFocusElement() ](#accessibilityextensioncontextgetfocuselementdeprecated)或者[AccessibilityExtensionContext.getWindowRootElement() ](#accessibilityextensioncontextgetwindowrootelementdeprecated)获取AccessibilityElement实例。
793
794**系统能力**:以下各项对应的系统能力均为SystemCapability.BarrierFree.Accessibility.Core
795
796### attributeNames<sup>(deprecated)</sup>
797
798attributeNames\<T extends keyof ElementAttributeValues>() : Promise\<Array\<T>>;
799
800获取节点元素的所有属性名称,使用Promise异步回调。
801
802> **说明:**
803>
804> 从API version 12开始废弃。
805
806**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
807
808**返回值:**
809
810| 类型                            | 说明                       |
811| ----------------------------- | ------------------------ |
812| Promise&lt;Array&lt;T&gt;&gt; | Promise对象,返回节点元素的所有属性名称。 |
813
814**示例:**
815
816```ts
817import { ElementAttributeKeys } from '@kit.AccessibilityKit';
818import { BusinessError } from '@kit.BasicServicesKit';
819
820// rootElement是AccessibilityElement的实例
821rootElement.attributeNames().then((data: ElementAttributeKeys[]) => {
822  console.log(`Succeeded in get attribute names, ${JSON.stringify(data)}`);
823}).catch((err: BusinessError) => {
824  console.log(`failed to get attribute names, Code is ${err.code}, message is ${err.message}`);
825});
826```
827
828### attributeNames<sup>(deprecated)</sup>
829
830attributeNames\<T extends keyof ElementAttributeValues>(callback: AsyncCallback\<Array\<T>>): void;
831
832获取节点元素的所有属性名称,使用callback异步回调。
833
834> **说明:**
835>
836> 从API version 12开始废弃。
837
838**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
839
840**参数:**
841
842| 参数名      | 类型                                  | 必填   | 说明                  |
843| -------- | ----------------------------------- | ---- | ------------------- |
844| callback | AsyncCallback&lt;Array&lt;T&gt;&gt; | 是    | 回调函数,返回节点元素的所有属性名称。 |
845
846**示例:**
847
848```ts
849import { ElementAttributeKeys } from '@kit.AccessibilityKit';
850import { BusinessError } from '@kit.BasicServicesKit';
851
852// rootElement是AccessibilityElement的实例
853rootElement.attributeNames((err: BusinessError, data: ElementAttributeKeys[]) => {
854  if (err && err.code) {
855    console.error(`failed to get attribute names, Code is ${err.code}, message is ${err.message}`);
856    return;
857  }
858  console.info(`Succeeded in get attribute names, ${JSON.stringify(data)}`);
859});
860```
861
862### attributeValue<sup>(deprecated)</sup>
863
864attributeValue\<T extends keyof ElementAttributeValues>(attributeName: T): Promise\<ElementAttributeValues[T]>;
865
866根据属性名称获取属性值,使用Promise异步回调。
867
868> **说明:**
869>
870> 从API version 12开始废弃。
871
872**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
873
874
875**参数:**
876
877| 参数名           | 类型   | 必填   | 说明       |
878| ------------- | ---- | ---- | -------- |
879| attributeName | ElementAttributeKeys  | 是    | 表示属性的名称。 |
880
881**返回值:**
882
883| 类型                                       | 说明                          |
884| ---------------------------------------- | --------------------------- |
885| Promise&lt;ElementAttributeValues[T]&gt; | Promise对象,返回根据节点属性名称获取的属性值。 |
886
887**错误码:**
888
889以下错误码的详细介绍请参见[无障碍子系统错误码](errorcode-accessibility.md)。
890
891| 错误码ID   | 错误信息                          |
892| ------- | ----------------------------- |
893| 401  | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
894| 9300004 | This property does not exist. |
895
896
897**示例:**
898
899```ts
900import { ElementAttributeKeys } from '@kit.AccessibilityKit';
901import { BusinessError } from '@kit.BasicServicesKit';
902
903let attributeName: ElementAttributeKeys = 'bundleName';
904
905// rootElement是AccessibilityElement的实例
906rootElement.attributeValue(attributeName).then((data: string) => {
907  console.log(`Succeeded in get attribute value by name, ${JSON.stringify(data)}`);
908}).catch((err: BusinessError) => {
909  console.error(`failed to get attribute value, Code is ${err.code}, message is ${err.message}`);
910});
911```
912
913### attributeValue<sup>(deprecated)</sup>
914
915attributeValue\<T extends keyof ElementAttributeValues>(attributeName: T,
916    callback: AsyncCallback\<ElementAttributeValues[T]>): void;
917
918根据属性名称获取属性值,使用callback异步回调。
919
920> **说明:**
921>
922> 从API version 12开始废弃。
923
924**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
925
926**参数:**
927
928| 参数名           | 类型                                       | 必填   | 说明                     |
929| ------------- | ---------------------------------------- | ---- | ---------------------- |
930| attributeName | ElementAttributeKeys                         | 是    | 表示属性的名称。               |
931| callback      | AsyncCallback&lt;ElementAttributeValues[T]&gt; | 是    | 回调函数,返回根据节点属性名称获取的属性值。 |
932
933**错误码:**
934
935以下错误码的详细介绍请参见[无障碍子系统错误码](errorcode-accessibility.md)。
936
937| 错误码ID   | 错误信息                          |
938| ------- | ----------------------------- |
939| 401  | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
940| 9300004 | This property does not exist. |
941
942**示例:**
943
944```ts
945import { ElementAttributeKeys } from '@kit.AccessibilityKit';
946import { BusinessError } from '@kit.BasicServicesKit';
947
948let attributeName: ElementAttributeKeys = 'bundleName';
949
950// rootElement是AccessibilityElement的实例
951rootElement.attributeValue(attributeName, (err: BusinessError, data: string) => {
952  if (err && err.code) {
953    console.error(`failed to get attribute value, Code is ${err.code}, message is ${err.message}`);
954    return;
955  }
956  console.info(`Succeeded in get attribute value, ${JSON.stringify(data)}`);
957});
958```
959
960### actionNames<sup>(deprecated)</sup>
961
962actionNames(): Promise\<Array\<string>>;
963
964获取节点元素支持的所有操作名称,使用Promise异步回调。
965
966> **说明:**
967>
968> 从API version 12开始废弃。
969
970**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
971
972**返回值:**
973
974| 类型                                 | 说明                         |
975| ---------------------------------- | -------------------------- |
976| Promise&lt;Array&lt;string&gt;&gt; | Promise对象,返回节点元素支持的所有操作名称。 |
977
978**示例:**
979
980```ts
981import { BusinessError } from '@kit.BasicServicesKit';
982
983// rootElement是AccessibilityElement的实例
984rootElement.actionNames().then((data: string[]) => {
985  console.log(`Succeeded in get action names, ${JSON.stringify(data)}`);
986}).catch((err: BusinessError) => {
987  console.error(`failed to get action names, Code is ${err.code}, message is ${err.message}`);
988})
989```
990
991### actionNames<sup>(deprecated)</sup>
992
993actionNames(callback: AsyncCallback\<Array\<string>>): void;
994
995获取节点元素支持的所有操作名称,使用callback异步回调。
996
997> **说明:**
998>
999> 从API version 12开始废弃。
1000
1001**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
1002
1003**参数:**
1004
1005| 参数名      | 类型                                       | 必填   | 说明                    |
1006| -------- | ---------------------------------------- | ---- | --------------------- |
1007| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | 是    | 回调函数,返回节点元素支持的所有操作名称。 |
1008
1009**示例:**
1010
1011```ts
1012// rootElement是AccessibilityElement的实例
1013rootElement.actionNames((err: BusinessError, data: string[]) => {
1014  if (err && err.code) {
1015    console.error(`failed to get action names, Code is ${err.code}, message is ${err.message}`);
1016    return;
1017  }
1018  console.info(`Succeeded in get action names, ${JSON.stringify(data)}`);
1019})
1020```
1021
1022### performAction<sup>(deprecated)</sup>
1023
1024performAction(actionName: string, parameters?: object): Promise\<void>;
1025
1026根据操作名称执行某个操作,使用Promise异步回调。
1027
1028> **说明:**
1029>
1030> 从API version 12开始废弃。
1031
1032**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
1033
1034**参数:**
1035
1036| 参数名         | 类型                                     | 必填   | 说明                                                       |
1037| ----------- | ---------------------------------------- | ---- |----------------------------------------------------------|
1038| actionName | string | 是    | 表示属性的名称,取值参考[Action](./js-apis-accessibility.md#action)。
1039| parameters | object | 否    | 表示执行操作时所需要的参数;默认为空。                             |
1040
1041**返回值:**
1042
1043| 类型                  | 说明               |
1044| ------------------- | ---------------- |
1045| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
1046
1047**错误码:**
1048
1049以下错误码的详细介绍请参见[无障碍子系统错误码](errorcode-accessibility.md)。
1050
1051| 错误码ID   | 错误信息                          |
1052| ------- | ----------------------------- |
1053| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1054| 9300005 | This action is not supported. |
1055
1056**示例:**
1057
1058```ts
1059import { BusinessError } from '@kit.BasicServicesKit';
1060
1061let actionName = 'action';
1062
1063// rootElement是AccessibilityElement的实例
1064rootElement.performAction(actionName).then(() => {
1065  console.info(`Succeeded in perform action,actionName is ${actionName}`);
1066}).catch((err: BusinessError) => {
1067  console.error(`failed to perform action, Code is ${err.code}, message is ${err.message}`);
1068});
1069```
1070
1071**无参数Action示例:**
1072
1073```ts
1074import { BusinessError } from '@kit.BasicServicesKit';
1075
1076// rootElement是AccessibilityElement的实例
1077// Action描述中无明确要求的,均为无参数Action
1078rootElement.performAction('click').then(() => {
1079  console.info(`Succeeded in perform action.`);
1080}).catch((err: BusinessError) => {
1081  console.error(`failed to perform action, Code is ${err.code}, message is ${err.message}`);
1082});
1083```
1084
1085**有参数Action示例:**
1086
1087```ts
1088import { BusinessError } from '@kit.BasicServicesKit';
1089
1090// rootElement是AccessibilityElement的实例
1091// setSelection示例代码
1092rootElement.performAction('setSelection', {
1093  selectTextBegin: '0', // 表示选择起始位置
1094  selectTextEnd: '8',   // 表示选择结束位置
1095  selectTextInForWard: true   // true表示为前光标,false表示为后光标
1096}).then(() => {
1097  console.info(`Succeeded in perform action`);
1098}).catch((err: BusinessError) => {
1099  console.error(`failed to perform action, Code is ${err.code}, message is ${err.message}`);
1100});
1101```
1102
1103```ts
1104import { BusinessError } from '@kit.BasicServicesKit';
1105
1106// rootElement是AccessibilityElement的实例
1107// setCursorPosition示例代码
1108rootElement.performAction('setCursorPosition', {
1109  offset: '1'   // 表示光标的设置位置
1110}).then(() => {
1111  console.info(`Succeeded in perform action`);
1112}).catch((err: BusinessError) => {
1113  console.error(`failed to perform action, Code is ${err.code}, message is ${err.message}`);
1114});
1115```
1116
1117### performAction<sup>(deprecated)</sup>
1118
1119performAction(actionName: string, callback: AsyncCallback\<void>): void;
1120
1121根据操作名称执行某个操作,使用callback异步回调。
1122
1123> **说明:**
1124>
1125> 从API version 12开始废弃。
1126
1127**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
1128
1129**参数:**
1130
1131| 参数名         | 类型                                     | 必填   | 说明             |
1132| ----------- | ---------------------------------------- | ---- | -------------- |
1133| actionName | string | 是    | 表示属性的名称,取值参考[Action](./js-apis-accessibility.md#action)。
1134| callback | AsyncCallback&lt;void&gt; | 是    | 回调函数,表示执行指定操作的回调。|
1135
1136**错误码:**
1137
1138以下错误码的详细介绍请参见[无障碍子系统错误码](errorcode-accessibility.md)。
1139
1140| 错误码ID   | 错误信息                          |
1141| ------- | ----------------------------- |
1142| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1143| 9300005 | This action is not supported. |
1144
1145**示例:**
1146
1147```ts
1148import { BusinessError } from '@kit.BasicServicesKit';
1149
1150let actionName = 'action';
1151
1152// rootElement是AccessibilityElement的实例
1153rootElement.performAction(actionName, (err: BusinessError) => {
1154  if (err && err.code) {
1155    console.error(`failed to perform action, Code is ${err.code}, message is ${err.message}`);
1156    return;
1157  }
1158  console.info(`Succeeded in perform action, actionName is ${actionName}`);
1159});
1160```
1161
1162### performAction<sup>(deprecated)</sup>
1163
1164performAction(actionName: string, parameters: object, callback: AsyncCallback\<void>): void;
1165
1166根据操作名称执行某个操作,使用callback异步回调。
1167
1168> **说明:**
1169>
1170> 从API version 12开始废弃。
1171
1172**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
1173
1174**参数:**
1175
1176| 参数名        | 类型                        | 必填   | 说明                                                          |
1177| ---------- | ------------------------- | ---- |-------------------------------------------------------------|
1178| actionName | string                    | 是    | 表示属性的名称,取值参考[Action](./js-apis-accessibility.md#action)。 |
1179| parameters | object                    | 是    | 表示执行操作时所需要的参数;默认为空。                                |
1180| callback   | AsyncCallback&lt;void&gt; | 是    | 回调函数,表示执行指定操作的回调。                                           |
1181
1182**错误码:**
1183
1184以下错误码的详细介绍请参见[无障碍子系统错误码](errorcode-accessibility.md)。
1185
1186| 错误码ID   | 错误信息                          |
1187| ------- | ----------------------------- |
1188| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1189| 9300005 | This action is not supported. |
1190
1191**示例:**
1192
1193```ts
1194import { BusinessError } from '@kit.BasicServicesKit';
1195
1196let actionName = 'action';
1197let parameters: object = [];
1198
1199// rootElement是AccessibilityElement的实例
1200rootElement.performAction(actionName, parameters, (err: BusinessError) => {
1201  if (err && err.code) {
1202    console.error(`failed to perform action, Code is ${err.code}, message is ${err.message}`);
1203    return;
1204  }
1205  console.info(`Succeeded in perform action,actionName is ${actionName}, parameters is ${parameters}`);
1206});
1207```
1208
1209### findElement('content')<sup>(deprecated)</sup>
1210
1211findElement(type: 'content', condition: string): Promise\<Array\<AccessibilityElement>>;
1212
1213根据节点内容查询所有节点元素,使用Promise异步回调。
1214
1215> **说明:**
1216>
1217> 从API version 12开始废弃。
1218
1219**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
1220
1221**参数:**
1222
1223| 参数名       | 类型     | 必填   | 说明                            |
1224| --------- | ------ | ---- | ----------------------------- |
1225| type      | string | 是    | 固定为'content', 表示查找的类型为节点元素内容。 |
1226| condition | string | 是    | 表示查找的条件。                      |
1227
1228**返回值:**
1229
1230| 类型                                       | 说明                            |
1231| ---------------------------------------- | ----------------------------- |
1232| Promise&lt;Array&lt;[AccessibilityElement](#accessibilityelement9)&gt;&gt; | Promise对象,返回满足指定查询关键字的所有节点元素。 |
1233
1234**错误码:**
1235
1236以下错误码的详细介绍请参见[无障碍子系统错误码](errorcode-accessibility.md)。
1237
1238| 错误码ID   | 错误信息                          |
1239| ------- | ----------------------------- |
1240| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1241
1242**示例:**
1243
1244```ts
1245import { BusinessError } from '@kit.BasicServicesKit';
1246
1247let condition = 'keyword';
1248
1249// rootElement是AccessibilityElement的实例
1250rootElement.findElement('content', condition).then((data: AccessibilityElement[]) => {
1251  console.log(`Succeeded in find element, ${JSON.stringify(data)}`);
1252}).catch((err: BusinessError) => {
1253  console.error(`failed to find element, Code is ${err.code}, message is ${err.message}`);
1254});
1255```
1256
1257### findElement('content')<sup>(deprecated)</sup>
1258
1259findElement(type: 'content', condition: string, callback: AsyncCallback\<Array\<AccessibilityElement>>): void;
1260
1261根据节点内容查询所有节点元素。
1262
1263> **说明:**
1264>
1265> 从API version 12开始废弃。
1266
1267**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
1268
1269**参数:**
1270
1271| 参数名       | 类型                                       | 必填   | 说明                           |
1272| --------- | ---------------------------------------- | ---- | ---------------------------- |
1273| type      | string                                   | 是    | 固定为'content',表示查找的类型为节点元素内容。 |
1274| condition | string                                   | 是    | 表示查找的条件。                     |
1275| callback  | AsyncCallback&lt;Array&lt;[AccessibilityElement](#accessibilityelement9)&gt;&gt; | 是    | 回调函数,返回满足指定查询关键字的所有节点元素。     |
1276
1277**错误码:**
1278
1279以下错误码的详细介绍请参见[无障碍子系统错误码](errorcode-accessibility.md)。
1280
1281| 错误码ID   | 错误信息                          |
1282| ------- | ----------------------------- |
1283| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1284
1285**示例:**
1286
1287```ts
1288import { BusinessError } from '@kit.BasicServicesKit';
1289
1290let condition = 'keyword';
1291
1292// rootElement是AccessibilityElement的实例
1293rootElement.findElement('content', condition, (err: BusinessError, data: AccessibilityElement[])=>{
1294  if (err && err.code) {
1295    console.error(`failed to find element, Code is ${err.code}, message is ${err.message}`);
1296    return;
1297  }
1298  console.info(`Succeeded in find element, ${JSON.stringify(data)}`);
1299});
1300```
1301
1302### findElement('focusType')<sup>(deprecated)</sup>
1303
1304findElement(type: 'focusType', condition: FocusType): Promise\<AccessibilityElement>;
1305
1306根据焦点元素类型查询节点元素,使用Promise异步回调。
1307
1308> **说明:**
1309>
1310> 从API version 12开始废弃。
1311
1312**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
1313
1314**参数:**
1315
1316| 参数名       | 类型                      | 必填   | 说明                                 |
1317| --------- | ----------------------- | ---- | ---------------------------------- |
1318| type      | string                  | 是    | 固定为'focusType', 表示查询的类型为节点的焦点元素类型。 |
1319| condition | [FocusType](#focustype) | 是    | 表示查询焦点元素的类型。                       |
1320
1321**返回值:**
1322
1323| 类型                                  | 说明                             |
1324| ----------------------------------- | ------------------------------ |
1325| Promise&lt;[AccessibilityElement](#accessibilityelement9)&gt; | Promise对象,返回满足指定查询焦点元素类型的节点元素。 |
1326
1327**错误码:**
1328
1329以下错误码的详细介绍请参见[无障碍子系统错误码](errorcode-accessibility.md)。
1330
1331| 错误码ID   | 错误信息                          |
1332| ------- | ----------------------------- |
1333| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1334
1335**示例:**
1336
1337```ts
1338import { FocusType } from '@kit.AccessibilityKit';
1339import { BusinessError } from '@kit.BasicServicesKit';
1340
1341let condition: FocusType = 'normal';
1342
1343// rootElement是AccessibilityElement的实例
1344rootElement.findElement('focusType', condition).then((data: AccessibilityElement) => {
1345  console.log(`Succeeded in find element,${JSON.stringify(data)}`);
1346}).catch((err: BusinessError) => {
1347  console.error(`failed to find element, Code is ${err.code}, message is ${err.message}`);
1348});
1349```
1350
1351### findElement('focusType')<sup>(deprecated)</sup>
1352
1353findElement(type: 'focusType', condition: FocusType, callback: AsyncCallback\<AccessibilityElement>): void;
1354
1355根据焦点元素类型查询节点元素,使用callback异步回调。
1356
1357> **说明:**
1358>
1359> 从API version 12开始废弃。
1360
1361**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
1362
1363**参数:**
1364
1365| 参数名       | 类型                                       | 必填   | 说明                                 |
1366| --------- | ---------------------------------------- | ---- | ---------------------------------- |
1367| type      | string                                   | 是    | 固定为'focusType', 表示查询的类型为节点的焦点元素类型。 |
1368| condition | [FocusType](#focustype)                  | 是    | 表示查询焦点元素的类型。                       |
1369| callback  | AsyncCallback&lt;[AccessibilityElement](#accessibilityelement9)&gt; | 是    | 回调函数,返回满足指定查询焦点元素类型的节点元素。          |
1370
1371**错误码:**
1372
1373以下错误码的详细介绍请参见[无障碍子系统错误码](errorcode-accessibility.md)。
1374
1375| 错误码ID   | 错误信息                          |
1376| ------- | ----------------------------- |
1377| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1378
1379**示例:**
1380
1381```ts
1382import { FocusType } from '@kit.AccessibilityKit';
1383import { BusinessError } from '@kit.BasicServicesKit';
1384
1385let condition: FocusType = 'normal';
1386
1387// rootElement是AccessibilityElement的实例
1388rootElement.findElement('focusType', condition, (err: BusinessError, data: AccessibilityElement)=>{
1389  if (err && err.code) {
1390    console.error(`failed to find element, Code is ${err.code}, message is ${err.message}`);
1391    return;
1392  }
1393  console.info(`Succeeded in find element, ${JSON.stringify(data)}`);
1394});
1395```
1396
1397### findElement('focusDirection')<sup>(deprecated)</sup>
1398
1399findElement(type: 'focusDirection', condition: FocusDirection): Promise\<AccessibilityElement>;
1400
1401根据下一焦点元素方向查询节点元素,使用Promise异步回调。
1402
1403> **说明:**
1404>
1405> 从API version 12开始废弃。
1406
1407**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
1408
1409**参数:**
1410
1411| 参数名       | 类型                                | 必填   | 说明                                       |
1412| --------- | --------------------------------- | ---- | ---------------------------------------- |
1413| type      | string                            | 是    | 固定为'focusDirection', 表示查询的类型为节点的下一焦点元素方向。 |
1414| condition | [FocusDirection](#focusdirection) | 是    | 表示查询下一焦点元素的方向。                           |
1415
1416**返回值:**
1417
1418| 类型                                  | 说明                               |
1419| ----------------------------------- | -------------------------------- |
1420| Promise&lt;[AccessibilityElement](#accessibilityelement9)&gt; | Promise对象,返回满足指定查询下一焦点元素方向的节点元素。 |
1421
1422**错误码:**
1423
1424以下错误码的详细介绍请参见[无障碍子系统错误码](errorcode-accessibility.md)。
1425
1426| 错误码ID   | 错误信息                          |
1427| ------- | ----------------------------- |
1428| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1429
1430**示例:**
1431
1432```ts
1433import { FocusDirection } from '@kit.AccessibilityKit';
1434import { BusinessError } from '@kit.BasicServicesKit';
1435
1436let condition: FocusDirection = 'up';
1437
1438// rootElement是AccessibilityElement的实例
1439rootElement.findElement('focusDirection', condition).then((data: AccessibilityElement) => {
1440  console.log(`Succeeded in find element, ${JSON.stringify(data)}`);
1441}).catch((err: BusinessError) => {
1442  console.error(`failed to find element, Code is ${err.code}, message is ${err.message}`);
1443});
1444```
1445
1446### findElement('focusDirection')<sup>(deprecated)</sup>
1447
1448findElement(type: 'focusDirection', condition: FocusDirection, callback: AsyncCallback\<AccessibilityElement>): void;
1449
1450根据下一焦点元素方向查询节点元素,使用callback异步回调。
1451
1452> **说明:**
1453>
1454> 从API version 12开始废弃。
1455
1456**系统能力**:SystemCapability.BarrierFree.Accessibility.Core
1457
1458**参数:**
1459
1460| 参数名       | 类型                                       | 必填   | 说明                                       |
1461| --------- | ---------------------------------------- | ---- | ---------------------------------------- |
1462| type      | string                                   | 是    | 固定为'focusDirection', 表示查询的类型为节点的下一焦点元素方向。 |
1463| condition | [FocusDirection](#focusdirection)        | 是    | 表示下一查询焦点元素的方向。                           |
1464| callback  | AsyncCallback&lt;[AccessibilityElement](#accessibilityelement9)&gt; | 是    | 回调函数,返回满足指定查询下一焦点元素方向的节点元素。              |
1465
1466**错误码:**
1467
1468以下错误码的详细介绍请参见[无障碍子系统错误码](errorcode-accessibility.md)。
1469
1470| 错误码ID   | 错误信息                          |
1471| ------- | ----------------------------- |
1472| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1473
1474**示例:**
1475
1476```ts
1477import { FocusDirection } from '@kit.AccessibilityKit';
1478import { BusinessError } from '@kit.BasicServicesKit';
1479
1480let condition: FocusDirection = 'up';
1481
1482// rootElement是AccessibilityElement的实例
1483rootElement.findElement('focusDirection', condition, (err: BusinessError, data: AccessibilityElement) =>{
1484  if (err && err.code) {
1485    console.error(`failed to find element, Code is ${err.code}, message is ${err.message}`);
1486    return;
1487  }
1488  console.info(`Succeeded in find element, ${JSON.stringify(data)}`);
1489});
1490```