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