I'm making a bot for a Flash game, and I've figured out how to import all the AutoIt functions into my C# code.
string title = "Minesweeper";
string full = auto.WinGetTitle(title,"");
string handle = auto.WinGetHandle(full, "");
if (auto.WinExists(full, "") == 1)
textBox1.Text = "window exists";
addressBox.Text = full;
for (int r = 1; r < 40; r++)
{
auto.ControlClick(full, "", "", "left", 2, r * 10, r * 10);
//auto.ControlClick(handle, "", "", "left", 2, r * 10, r * 10);
}
(I'm pretty sure the uncommented one should be the one with handle and vice versa, but this works for Minesweeper.)
So it works for Minesweeper and doesn't require it to be the active window. When I try to make it work on my Flash game it requires the Internet Explorer window to be the active one. Is this something Flash requires or is there something additional that I could do to make it work when the game is minimized?
This doesn't have to be done using the AutoIt imports. I tried SendMessage from user32 at one point also, but that didn't work for Flash content at all for me.
I just tested this on a random website instead of a Flash site or Minesweeper and for some reason the code works if I execute it from within the Autoit scripting program, but not from my C# program...
June 20th, 2012: I am pretty sure this has something to do with the way the handle gets passed. I've done some tests with calling an AutoIt EXE file and using the handle I get from the C# code as an argument, I have to add an 0x
to it, and also then within the AutoIt code I have to cast it from a string to an HWnd, so that could be something, in which case I don't know what to do since the imported function relies on a string input for the handle.