Home > Language Reference > Capture Functions > CaptureArea$

CaptureArea$

The CaptureArea$ function returns the text displayed in the specified area of a window.

Usage

Used to test the content of a window.

Video: How to use the WinTask CaptureArea$ function for retrieving a text displayed in a window.

Syntax

var$=CaptureArea$(<window_name>, <x>, <y>, <height>, <width>)

Parameters

<window_name>, string, name of the window to capture. The <window_name> must include the instance number.

<x>,<y>, integer, coordinates of the topleft point of the area to capture.

<height>,<width>, integer, size of the area to capture.

Return value

var$, string. It contains the captured text. If <window_name> is not found, or if there is nothing to capture, an empty string is returned (an emty string is "").

Remarks

Generate the CaptureArea$ syntax using its wizard: in the Language pane of the WinTask Editor, double-click the CaptureArea$ function name to start the wizard (if the Language pane is not displayed, press F4 or select Insert/Statement menu).

If the size of the specified area is greater than the size of the specified window, the captured area is limited to the entire window.

PERFORMANCE: CaptureArea$ activates a complex analysis process (0.9 second). If you need better performance, you can automate those steps:
select text then copy it into the clipboard (via Ctrl+C) then get its content with GetClipBoard$ function.

See also

Capture$
CaptureAreaOCR$
CaptureBitmap
CaptureOCR$
HardCopy

Example

Shell("notepad",1)

UseWindow("NOTEPAD.EXE|Edit|Untitled - Notepad|1",1)
'Type some text in the Notepad window
 SendKeys("First line to capture<Enter>")
 SendKeys("<Enter>")
 SendKeys("   Zone to capture<Enter>")
 SendKeys("   Second line in the zone<Enter>")
 SendKeys("<Enter>")
'Capture the text in the area starting at Zone to capture and ending at in the zone.
a$=CaptureArea$("NOTEPAD.EXE|Edit|Untitled - Notepad|1",1,31,34,44,264)
msgbox(a$)