So I'm trying to find a certain pattern in the middle of the screen in a given area. I'm using the AutoItX
library and the PixelSearch
method.
- Rectangle X: 1980
- Rectangle Y: 630
- Rectangle Size X: 1240
- Rectangle Size Y: 180
It's not returning that the pattern has been found, but if I adjust the cords of the rectangle to 0, 0
it shows that the pattern has been found.
The following script used:
public void MonsterScan()
{
if(SixStarMax() == true)
{
Console.WriteLine("Pattern found");
}
}
public bool SixStarMax()
{
Rectangle rect = new Rectangle(1980, 630, 1240, 180);
autoSumPoint = AutoItX.PixelSearch(rect, 0xF8F0E0); // 0xF8F0E0
autoSumPoint2 = AutoItX.PixelSearch(rect, 0xB7AD9F); // 0xB7AD9F
autoSumPoint3 = AutoItX.PixelSearch(rect, 0xCDC6B8); // 0xCDC6B8
autoSumPoint4 = AutoItX.PixelSearch(rect, 0x949084); // 0x949084
if (rect.Contains(autoSumPoint2) == true && rect.Contains(autoSumPoint2) == true && rect.Contains(autoSumPoint3) == true && rect.Contains(autoSumPoint4) == true)
{
AutoItX.MouseMove(autoSumPoint.X, autoSumPoint.Y);
return true;
}
else
{
return false;
}
}
Edit:
Tried to adjust the cordinates to my first screen and I get an error thrown.
System.AccessViolationException: 'An attempt was made to read or write to protected memory. This often indicates that other memory is damaged. '