Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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

http://watin.sourceforge.net/

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top