views:

564

answers:

7

[Note: edited q. for the bounty and to make it clear, but q. remains the same]

I'm looking for a library that can be used in native .NET code, just like any .NET assembly. The purpose of the library must be to automate Windows (push a button, select a window, send keys, record & playback, that sort of thing).

So: the library is supposed to be used natively in .NET, but the automation itself must be able to target any native or .NET Windows application that can receive user input.


Suggestions so far:

If nothing else appears available, I'll probably choose Microsoft's UI Automation and upgrade any projects that require it that are still in .NET 2.0 to .NET 3.5, if possible. But I hope for a more widely applicable automation framework (.NET prior to 2.0 does not need to be supported).

+4  A: 

microsoft's own built in one is fine

http://msdn.microsoft.com/en-us/library/ms747327.aspx

not restricted to wpf as some seem to think.

pm100
I wasn't aware of this new development. Surely interesting, but it locks me down to WPF. Considering I nearly only do .NET 3.5+ development (when I do .NET projects, that is) that shouldn't be a real problem though.
Abel
I don't think this locks you into WPF; it's the Windows standard UI automation library, and just happens to work with WPF now. MS Active Accessibility is your best option if you need to work downlevel.
JasonTrue
nothing to do with wpf. works for all ui in windows
pm100
I don't seem to make myself very clear, sorry about that. I want to use the libs from programming code. Which requires WPF (which isn't a problem). Yes, of course it can automate anything in Windows, I totally understand, but that wasn't the point... ;-)
Abel
+1. As recommended in MSDN magazine http://msdn.microsoft.com/en-us/magazine/cc163465.aspx
MarkJ
It was a tough decision between your answer and White. But White is so much easier to use, it really takes away the complexity of Microsoft UI Automation, while still being able to falling back to the core if I want or need to. It is still in development, but it has potential. Both are WPF, no basic .NET application can use the lib, you need to include WPF. But that's just something I have to accept (or use hardcode AutoIt or CSharpScript).
Abel
+4  A: 

I have used AutoIt in the past with success.

benPearce
Looks quite like something I need (and it rings a bell, too). Tx
Abel
Beat me to it! :) Yes, I would say check out AutoItX, which is a way to use AutoIt functionality from a DLL.
Adam Neal
Since I actually asked for a .NET lib: I don't imm. see how it can be used from within .NET. Can you either show an example or point to one how it can be called from .NET?
Abel
Some ruby test automation libraries do it by essentially creating a pipe to the I/O of the AutoIt executable. Ugly but it works.
JasonTrue
I think the bit of info missing is that AutoIt automates at the Windows level not .Net level, so pressing buttons on a form or setting contents of a textbox, could be any form.
benPearce
that's not really what I mean, I fully understand that it's possible to use AutoIt to automate an existing .NET program. But how can you create a .NET program that uses AutoIt (like a lib or a .NET assembly) to automate Windows.
Abel
If you include either the executable or the DLL version (AutoItX), you can either use the hacky method (System.Process.Start, for example) and call the AutoIt command-line app, or you can use normal DLL Interop mechanisms if you're using the DLL.
JasonTrue
Jason, thanks for the explanation, I totally agree and understand. But I was looking for .NET library. Calling into native code using interop is not what I call calling a .NET library...
Abel
+1  A: 

Check out Tools for automated GUI testing on windows

SwDevMan81
Good list, comes down to AutoIt of BenPearce, effectively ;-)
Abel
+1  A: 

I have used WebAii from ArtOfTest with a fair degree of success in automating integration testing for a Silverlight app. It also supports WinForms and Web applications.

Microsoft UI Automation, the successor to Active Accessibility, can do almost all of the Windows UI automation you would need.

JasonTrue
Correct me if I'm wrong, but isn't that browser-automation? I'm really looking for Windows automation. Interesting to keep, though for other types of projects :)
Abel
You're right, it's certainly more focused on that domain, but it exposes Win32 controls as well. Microsoft UI Automation works for most automation that doesn't have to interact with browsers. http://en.wikipedia.org/wiki/Microsoft_UI_Automation
JasonTrue
+1  A: 

This library is pretty interesting and is fairly simple. Perhaps it will help you.

Chris Dunaway
That's definitely interesting! Not actually an automation lib per se, but it's surely usable and up to that task it seems. I'll have a deeper look at it.
Abel
+2  A: 

Have you looked at the White framework?

testmann
Thanks for your answer. It looks good and it takes the pain away of using the UI Framework of WPF. However, it has the same drawbacks as WPF (when called from WinForms for instance), but it is possibly the best solution so far.
Abel
If you also have external Controls, you may want to verify that they can be automated with White: In this case you might want to use this http://www.codeplex.com/UIAutomationVerify .
tobsen
After some thought I decided to accept your answer. It is not exactly what I wanted (it limits me to use WPF when I want to include White or MS UI Automation), but it's arguably the best offer so far. Thanks!
Abel
+1  A: 

How about CSharpScript, here's an article about it on Codeproject, and here's the link to the main website. Furthermore, it is familiar C#, scripted which can be used to automate anything.

Hope this helps, Best regards, Tom.

tommieb75
That looks like a promising project that has its merits, but being a scripting language, how can it be applied for automation of "any" Windows application?
Abel
I wouldn't define it as a scripting language per se, the C# code can be used as a program in its own right, if you think of the Windows Scripting Host, or even AutoIt, even use p/invoke in the code, that's the flexibility of it.
tommieb75