How to Automate simple Windows Form Application using MSAA?

徘徊边缘 提交于 2021-02-19 06:45:08

问题


I want to automate simple Windows Application using MSAA. I am not getting Idea that how to find the control (say TextBox and Button) and to get value of them(say get value of TextBox and click in case of button).


回答1:


Why do you want to automate using MSAA? Microsoft's current way is UI Automation.

From Wikipedia (emphasis mine):

UIA is similar to Microsoft Active Accessibility (MSAA) in that it provides a means for exposing and collecting information about user interface elements and controls to support user interface accessibility and software test automation. However, UIA is a newer technology that provides a much richer object model than MSAA...

With UI Automation you can automate by creating a native or .NET application or use a 3rd party tool like RIATest that relies on UI Automation.

(Disclamer: I am affiliated with RIATest).




回答2:


The following assumes you'll be developing your automation program in C/C++, as I'm not sure it would be easy to use MSAA from .NET (it might be possible though!)

If you don't want to use C++, you might investigate using MS UI Automation from .NET.

To get started developing an automation client app using MSAA and C++, I suggest:

  1. Install the Windows SDK for Windows 7 and .NET Framework 4

  2. That will install the Inspect.exe tool - find it under:

    Programs > Microsoft Windows SDK v7.1 > Tools > Inspect Objects

  3. Launch Inspect.exe and switch the upper left dropdown menu from "UI Automation" to "MSAA"

  4. Launch your application under test and mouse over its UI elements - the MSAA properties of the elements should display in Inspect.exe

  5. Write your automation code :)

An important choice will be to decide whether to use event-driven techniques to locate your elements, or simply start at the top level (the desktop), find your app among the child elements of the desktop, and drill down into your app's element tree from there.

There's a good event-driven MSAA tutorial on codeproject.com at: http://www.codeproject.com/Articles/18290/Introduction-to-Microsoft-Active-Accessibility

Tutorials on tree-based navigation in MSAA seem a little more scarce. I would start with the MS docs - I recommend the first one:

Active Accessibility Client Interfaces and Functions

Active Accessibility User Interface Services

Active Accessibility Start Page



来源:https://stackoverflow.com/questions/15499293/how-to-automate-simple-windows-form-application-using-msaa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!