The CaptureArea$ function returns the text displayed in the specified area of a window.
Used to test the content of a window.
Video: How to use the WinTask CaptureArea$ function for retrieving a text displayed in a window.
var$=CaptureArea$(<window_name>, <x>, <y>, <height>, <width>)
<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.
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 "").
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.
UseWindow("NOTEPAD.EXE|Edit|Untitled - Notepad|1",1)
'Type some text in the Notepad window
SendKeys("First line to capture<Enter>")
SendKeys(" Zone to capture<Enter>")
SendKeys(" Second line in the zone<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)