I'm using AutoItX library to search for a pixel in a certain area. Unfortunately it always returns X=0, Y=0 on whatever coordinates or color for the PixelSearch
method. I can't find any documentation either.
Code:
var rgb = desiredPixelColor.ToArgb();
Rectangle rect = new Rectangle()
{
X = 200,
Y = 200,
Width = 400,
Height = 400
};
try
{
Process p = Process.GetProcessById(ID);
if (p != null)
{
IntPtr h = p.MainWindowHandle;
SetForegroundWindow(h);
var search = AutoItX.PixelSearch(rect, rgb);
Thread.Sleep(5000);
if (!search.IsEmpty)
{
DoubleClickAtPos(search.X, search.Y);
return true;
}
}
}
catch
{
MessageBox.Show("No pixel found");
}
No matter what coordinates or color, PixelSearch
always returns 0 values. Not even null. Also tried smaller values but the result is always the same.