Method uiimage.waitNot
Overload
Waits until image(s) or color(s) is not displayed in a window or other area. More info: uiimage.find.
public static bool waitNot(Seconds timeout, IFArea area, IFImage image, IFFlags flags = 0, int diff = 0, Func<uiimage, IFAlso> also = null)
Parameters
timeout (Seconds)
Timeout, seconds. Can be 0 (infinite), >0 (exception) or <0 (no exception). More info: Wait timeout. |
area (IFArea)
Where to search:
|
image (IFImage)
Image or color to find. Or array of them. More info: IFImage. |
flags (IFFlags) |
diff (int)
Maximal allowed color difference. Can be 0 - 100, but should be as small as possible. Use to find images with slightly different colors than the specified image. |
also (Func<uiimage, IFAlso>)
Callback function. Called for each found image instance and receives its rectangle, match index and list index. Can return one of IFAlso values.
|
Returns
bool
Returns |
Exceptions
TimeoutException
timeout time has expired (if > 0). |
AuWndException
Invalid window handle (the area argument), or the window closed while waiting. |
ArgumentException
An argument is/contains a |
FileNotFoundException
Image file does not exist. |
Exception
Exceptions of ImageUtil.LoadGdipBitmap. |
AuException
Something failed. |
Remarks
To create code for this function, use tool Find image or color in window.
The speed mostly depends on:
- The size of the search area. Use the smallest possible area (control or UI element or rectangle in window).
- Flags IFFlags.WindowDC (makes faster), IFFlags.PrintWindow. The speed depends on window.
- Video driver. Can be much slower if incorrect, generic or virtual PC driver is used. The above flags should help.
- diff. Should be as small as possible.
If flag IFFlags.WindowDC or IFFlags.PrintWindow not used, the search area must be visible on the screen, because this function then gets pixels from the screen.
Can find only images that exactly match the specified image. With diff can find images with slightly different colors and brightness.
Transparent and partially transparent pixels of image are ignored. You can draw transparent areas with an image editor that supports it, for example Paint.NET.
This function is not the best way to find objects when the script is intended for long use or for use on multiple computers or must be very reliable. Because it may fail to find the image after changing some settings - system theme, application theme, text size (DPI), font smoothing (if the image contains text), etc. Also are possible various unexpected temporary conditions that may distort or hide the image, for example adjacent window shadow, a tooltip or some temporary window. If possible, in such scripts instead use other functions, eg find control or UI element.
Flags IFFlags.WindowDC and IFFlags.PrintWindow cannot be used if area is Bitmap or RECT.
Examples
Code created with tool Find image or color in window.
var w = wnd.find(1, "Window Name");
string image = "image:iVBORw0KGgoAAAANSUhEUgAAABYAAAANCAYAAACtpZ5jAAAAAXNSR0IArs4c...";
var im = uiimage.find(1, w, image);
im.MouseClick();