Programming attempt of MS Active accessibility interface Technology

Source: Internet
Author: User
Tags function definition implement win32

Microsoft© Active Accessibility 2.0 is a COM-based technology that improves the
way accessibility aids work with applications running on Microsoft Windows?. It
provides dynamic-link libraries that are incorporated into the operating system
as well as a COM interface and application programming elements that provide
reliable methods for exposing information about user interface elements.   

Basis

Microsoft©active accessibility is a relatively new technology (1.0 edition launched in May 1997). The aim is to facilitate people with disabilities to use computers--for amplifiers, screen readers, and tactile mice. It can also be used to develop applications that drive other software, and its ability to simulate user input is especially appropriate for testing software development.

The main idea of Active accessibility is to provide a way to programmatically access UI element information or manipulate these UI elements. UI (User Interface) elements that support this feature are accessible. In most cases, this means that a UI element supports the IAccessible interface. You can also say that in an Active accessibility world, an accessible UI element can be represented as a iaccessible interface.

Whenever you need to get information about an element, perform an action on it, or do something else with Active accessibility, you typically refer to this element by using a method or property that represents the IAccessible interface for that element.

Active Accessibility principle

Active accessibility? The core functions of the OLEACC. DLL provided by the. Each time you call a function to return a IAccessible interface pointer, it corresponds to a UI element, OLEACC. DLL to check whether this element supports iaccessible internally. Intrinsic support means that the iaccessible of the element is implemented by a program.

When a UI element cannot support IAccessible internally, OLEACC. DLL to check the Windows class name of the element. If the class is a USER or COMCTL32-supported class, OLEACC. DLL to create an agent to implement the IAccessible interface for UI elements. Most-but not all--comctl32 controls have been OLEACC. DLL supports the IAccessible interface.

Examples of built-in UI elements that support IAccessible are custom controls, Owner-drawn, and windowless controls. Because developers create programs that contain these UI elements, they also implement the interface of these elements, and they have the responsibility to provide correct support for these methods and attributes.

If you use a standard control, it also means that you do not have to rewrite your application, and these applications are automatically compatible with Active Accessibility.

The Active accessibility name is based on the name of the Win32 control, and the role is based on the function definition of the control.

How to get the IAccessible interface pointer

Whenever you need information about an element, perform an action on it, or use Active accessibility to do something else, you only need to refer to the element by using a method or attribute that represents the IAccessible interface for that element.

There are several ways to get pointers that represent an IAccessible interface that can access UI elements. The most common approach is to use a function provided by Active accessibility, such as Accessibleobjectfrompoint,accessibleobjectfromwindow, or use the IAccessible Supported methods, such as Get_accchild,get_accparent.

The IAccessible interface supports attributes that allow you to get information about each UI element, and the most important attributes for an example program are name, role, and state.

The Active Accessibility SDK provides handy tools for Object Inspector to display the properties of the UI element that the cursor points to. Object Inspector shows how the world of Active accessibility becomes universal because it has control over the IAccessible interface within a selected window. In addition to searching for information about elements and controlling elements through the IAccessible interface, Active accessibility? There are two other features that are useful for example programs: monitoring events that occur with UI elements and simulating keyboard and mouse input. Events fired by an accessible element are called winevents, which fires when an accessible element is created or when the name, state, position, or keyboard focus changes (the event mechanism resembles the standard Windows hook mechanism.) Monitoring events we will introduce later. )。 A list of these events is shown in document Winable. H. The name of each event begins with Event_object or Event_system.

Well, let's get back to the point of getting the IAccessible interface pointer. As mentioned earlier, the function provided by Accessibleobjectfromwindow this Active accessibility can literally be seen through a window to get the corresponding IAccessible interface pointer.

Because the number of iaccessible interfaces is larger than Windows (because most-but not all--comctl32 controls are OLEACC). DLL supports the IAccessible interface. , using the Win32 function to search for a window will take much less time than using the Active accessibility tree to search for the corresponding IAccessible interface to the window. This means that in order to improve performance, you should use the WIN32 functions such as FindWindow and EnumWindows to find the closest window to the desired UI element. Of course, when weighing Win32 functions and Active accessibility functions, the rules above are simply using their general criteria and not being followed blindly, it is important to understand their original meaning.

The following code describes its usage.

We came down to the IAccessible interface pointer for the following run window.

Figure I

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.