问题
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:
Install the Windows SDK for Windows 7 and .NET Framework 4
That will install the Inspect.exe tool - find it under:
Programs > Microsoft Windows SDK v7.1 > Tools > Inspect Objects
Launch Inspect.exe and switch the upper left dropdown menu from "UI Automation" to "MSAA"
Launch your application under test and mouse over its UI elements - the MSAA properties of the elements should display in Inspect.exe
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