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 minesweepers)
So it works for minsweepers and doesn't require it to be the active window. When I try to make it work on my flash game it requires the IE 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.
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: Pretty sure this has something to do with the way the handle gets passed, I've done some tests with calling an autoit exe 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.