Show / Hide Table of Contents

Method ocr.find(+ 1 overload)


Overload

Performs OCR (text recognition) and finds text in results.

public static ocr find(IFArea area, string text, OcrFlags flags = 0, double scale = 0, IOcrEngine engine = null, int skip = 0)
Parameters
area  (IFArea)

On-screen area or image:

  • wnd - window or control (its client area).
  • elm - UI element.
  • System.Drawing.Bitmap - image.
  • RECT - a rectangle area in screen.
  • IFArea - can contain wnd, elm or Bitmap. Also allows to specify a rectangle in it, which makes the area smaller and the function faster. Example: new(w, (left, top, width, height)).
text  (string)

Text to find in ocr.TextForFind. Can have prefix:

  • "**r " - PCRE regular expression. Example: @"**r \bwhole words\b".
  • "**R " - .NET regular expression.
  • "**i " - case-insensitive.
  • "**t " - case-sensitive (default).
flags  (OcrFlags)
scale  (double)

Scale factor (how much to resize the image before performing OCR). Value 2 or 3 may improve results of OCR engine OcrWin10 or OcrTesseract. If 0 (default), depends on engine's IOcrEngine.DpiScale and area's DPI.

engine  (IOcrEngine)

OCR engine. Default: ocr.engine (OcrWin10 if not specified).

skip  (int)

Skip this count of found text instances.

Returns
ocr

Returns an ocr object that contains the word index and can click it etc. Returns null if not found.

Exceptions
AuWndException

Invalid window handle (the area argument).

ArgumentException

An argument is/contains a null/invalid value.

AuException

Something failed.

Remarks

The function captures image from screen or window (unless area is Bitmap) and passes it to the OCR engine (calls IOcrEngine.Recognize). Then finds the specified text in results. If found, creates and returns an ocr object that contains results.

The speed depends on engine, area size and amount of text.


Overload(top)

Performs OCR (text recognition) and finds text in results. Can wait and throw NotFoundException.

public static ocr find(Seconds wait, IFArea area, string text, OcrFlags flags = 0, double scale = 0, IOcrEngine engine = null, int skip = 0)
Parameters
wait  (Seconds)

The wait timeout, seconds. If 0, does not wait. If negative, does not throw exception when not found.

area  (IFArea)

On-screen area or image:

  • wnd - window or control (its client area).
  • elm - UI element.
  • System.Drawing.Bitmap - image.
  • RECT - a rectangle area in screen.
  • IFArea - can contain wnd, elm or Bitmap. Also allows to specify a rectangle in it, which makes the area smaller and the function faster. Example: new(w, (left, top, width, height)).
text  (string)

Text to find in ocr.TextForFind. Can have prefix:

  • "**r " - PCRE regular expression. Example: @"**r \bwhole words\b".
  • "**R " - .NET regular expression.
  • "**i " - case-insensitive.
  • "**t " - case-sensitive (default).
flags  (OcrFlags)
scale  (double)

Scale factor (how much to resize the image before performing OCR). Value 2 or 3 may improve results of OCR engine OcrWin10 or OcrTesseract. If 0 (default), depends on engine's IOcrEngine.DpiScale and area's DPI.

engine  (IOcrEngine)

OCR engine. Default: ocr.engine (OcrWin10 if not specified).

skip  (int)

Skip this count of found text instances.

Returns
ocr

Returns an ocr object that contains the word index and can click it etc. If not found, throws exception or returns null (if wait negative).

Exceptions
NotFoundException
AuWndException

Invalid window handle (the area argument), or the window closed while waiting.

ArgumentException

An argument is/contains a null/invalid value.

AuException

Something failed.

Remarks

The function captures image from screen or window (unless area is Bitmap) and passes it to the OCR engine (calls IOcrEngine.Recognize). Then finds the specified text in results. If found, creates and returns an ocr object that contains results.

The speed depends on engine, area size and amount of text.