views:

1708

answers:

4

I'm trying to automate some stuff on a flash game running in a webbrowser control in my C# program. Using user32's sendmessage dll I've been able to click at coordinates on regular pages such as google but it doesn't work on flash content. Any ways I can do this? Also it cannot be detectable to the flash game. I have a working one in autoit but I'd like to rewrite it in c# and make it work minimized.

+2  A: 

Check out WatiN. Powerful browser automation, compatible with C#:

http://watin.sourceforge.net/

JerSchneid
Great tool. Thank you.
Robert Venables
Yeah, WatiN is great... try that if the selected answer doesn't work for you.
Jeff Wilcox
+3  A: 

Why not just call your Autoit/Autohotkey script from your C# program using the System.Diagnostics.Process class?

ProcessStartInfo psi = new ProcessStartInfo("your_script.ahk");
psi.CreateNoWindow = true;

Process procScript = Process.Start(psi);
procScript.WaitForExit();

Notice the CreateNoWindow=true to ensure it runs hidden, and the WaitForExit(), to make your code wait for the process to return.

AutoIt and AutoHotkey have some very powerful automation commands that have been refined over the years. It's very hard to reproduce similar C#/.NET functionality that is just as reliable, believe me I've tried.

Ash
+1  A: 

Ranorex might be very interesting for. You can easily capture/replay your flash and web application UI tests, edit your actions and generate a fully functional C# code.

www.ranorex.com

gherget
+1  A: 

Using SendMessage or PostMessage will work. You need to send 3 messages, WM_MOUSEMOVE, then WM_MOUSEDOWN, then WM_MOUSEUP. The WM_MOUSEMOVE must indicate a location different from the WM_MOUSEDOWN and WM_MOUSEUP. WM_MOUSEDOWN and WM_MOUSEUP should be in the same location. Works for me.

Eyal