The function compares the image of the control with an other image on the screen.
The positions are given in screen coordinates that are relative to the upper-left corner of the screen.
The function returns true, if the the two images are identical, otherwise false.
Supported only in RanorexPro.
The following sample searches the image "TrackBar.bmp" in the ToolStrip and returns the location
of the first pixel in the control if the image could be found.
The sample uses the CompareImage function to demonstrate how to compare an image loaded from a file
with an other image in the control.
CopyC#
The following example searches and compares the image "MyImage.bmp" in the first subitem of a ListView.
CopyC#
Point point; if (toolStrip.FindImage("TrackBar.bmp", out point) == true) { Point offset = new Point(point.X - toolStrip.Location.X, point.Y - toolStrip.Location.Y); Console.WriteLine("ToolStrip Image \"TrackBar.bmp\" found at Location= {0} Offset= {1}", point, offset); if (toolStrip.CompareImage("TrackBar.bmp", offset) == true) Console.WriteLine("ToolStrip ImageCompare OK"); Mouse.Move(point); }
for (int index = 1; index < itemCount; index++) { Point location = listView.GetSubItemLocation(index, 1, false); Size size = listView.GetSubItemSize(index, 1, false); string imageFileName = "MyImage.bmp"; Point point; if (listView.FindImage(imageFileName, out point, location, size) == true) { Console.WriteLine(" Image found Index={0} Name={1} {2} {3}", index, listView.GetItemText(index, 0), location, size); Point offset = new Point(point.X - listView.Location.X, point.Y - listView.Location.Y); if ( listView.CompareImage(imageFileName, offset) == true ) Console.WriteLine(" Image compare OK"); Mouse.Click(MouseButtonType.LeftButton, point.X, point.Y); } }
