Automating UI on Windows 7 platform
I am a beginner in C++ application development. I use Visual开发者_开发百科 Studio and I have an application which process the image like Photoshop does. I wish to automate the UI of my app and test various scenarios automatically by saving processed files. I use Visual studio on my Win 7 machine for development, do not have .NET. What options I have to automate my testing?
Thanks
On Windows 7 (and Vista/XP, if you install an update) you can use the COM-based Microsoft UI Automation API to write UI automation clients in C++.
I've successfully automated the UI of Windows apps this way. It works pretty well, and with a little extra work can even be called from C-based scripting language interpreters that understand COM (e.g. Python and Ruby).
Finding documentation on the UIA COM API can be a little tricky since searches for "MS UI Automation" usually turn up info on the .NET interface rather than the COM interface (the COM interface is much newer and not as well-known).
As Boann mentions you can use third-party libraries too, like AutoIt. That can ease some of the learning curve and extra work. AutoIt exposes its own COM interface (AutoItX) that you can likely use from a C++ app.
If you want to read about writing COM UIA apps in C++ here are some links to get started:
The UI Automation Client Programmer's guide on MSDN:
http://msdn.microsoft.com/en-us/library/ee684021(v=VS.85).aspx
http://msdn.microsoft.com/en-us/library/ee671216(v=VS.85).aspx
The IUIAutomation interface:
http://msdn.microsoft.com/en-us/library/windows/desktop/ee671406(v=vs.85).aspx
A couple of helpful articles with sample code:
http://www.code-magazine.com/articleprint.aspx?quickid=0810052&printmode=true
http://blogs.msdn.com/b/winuiautomation/archive/2011/05/18/building-ui-automation-client-applications-in-c-and-c.aspx
Windows accessibility and automation forum:
http://social.msdn.microsoft.com/Forums/en-US/windowsaccessibilityandautomation/threads
A language called AutoIt Script is designed specifically for Windows UI automation. Sadly it's a Basic-like rather than C-like language, but it does what it says well: http://www.autoitscript.com/site/autoit/
精彩评论