Python iaccessible Interface

Source: Internet
Author: User

Msaa stands for Microsoft Active accessibility. This is similar to DCOM technology. The technical model is like this, UIProgramYou can expose an interface to allow another program to control it. The original intention of msaa technology is to facilitate the use of Windows programs for the disabled. For example, a blind person cannot see a window, but a blind person can connect to a computer through a USB reading screen, and the reading screen can obtain program information through the interface exposed by the UI program, transmitted to the blind in Braille or other forms.

Msaa provides such convenient functions that can naturally be used for UI automated testing. The interface exposed by msaa is called iaccessible.

To obtain the iaccessible interface in Python, follow these steps:

From Ctypes Import Windll, oledll, winerror, byref, pointer
From Ctypes. wintypes Import Point

FromComtypesImportComerror
FromComtypes. AutomationImportVariant
FromComtypes. ClientImportGetmodule

# Create wrapper for the oleacc. DLL Type Library
getmodule ( " oleacc. DLL " )
# import the interface we need from the wrapper
from comtypes. gen. accessibility Import iaccessible

def accessibleobjectfrompoint (x, y ):
" return an accessible object and an index. see msdn for details. "
PACC = pointer (iaccessible) ()
var = variant ()
oledll. oleacc. accessibleobjectfrompoint (point (x, y), byref (PACC),
byref (VAR)
return pACC, VAR

DefAccessibleobjectfromwindow (hwnd ):
PTR=Pointer (iaccessible )()
Res=Oledll. oleacc. accessibleobjectfromwindow (
Hwnd, 0,
Byref (iaccessible. _ IID _), byref (PTR ))
ReturnPTR

Related Article

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.