I've been working on something similar to "IronAHK" (an old library where they tried to port AHK to .net); I'm not necessarily trying to do that per se, because .net has tons of AHK's functionality already (a GUI framework, a Sleep function, string handling, File I/O, it can call functions in DLLs etc.). So I'm really focusing on:
- Windows (WinExist, WinActivate, WinClose etc.)
Controls (ControlClick, ControlSend, etc.)
Hotkeys
Sending keystrokes and mouse clicks (.net can do some of this though)
Anyway I would LOVE to add ImageSearch to the list! But my C++ skills are not to the point (yet) where I can look at arbitrary code and figure out how it works. I've been looking at the AHK source lately, and can't seem to find the implementation details. There seems to be a class called "Line" that seems to handle a lot of stuff (I'm guessing it's the guts of the AHK interpreter, which decides what to do on a line-by-line basis), but I'm not seeing a Line::ImageSearch definition anywhere.
So my next step was to do like I did with the window functions - just get it done in C#. I tried Get/SetPixel (which I see is used for PixelGetColor) and soon found out how slow that was; frm there I tried using the .net Bitmap object and its LockBits method, and that came up with something that worked but was still way slower than AHK's version. I've also considered libraries like OpenCV and EmguCV (which I'd love to learn if I could follow the math ) but in the end AHK still seems to have the simplest, fastest algorithm out there. Anyone here know how it works?
If not, another option I'm considering is writing an AHK script that I can compile to an EXE and call from C# passing the parameters through the command line. I actually got this working, but I'm thinking the overhead of running an external program might slow things down a bit (or would it?). Thanks guys.