Introduction
Welcome to this tutorial on using WinTask’s OCR (Optical Character Recognition) function. In this session, we will demonstrate how to extract text from images or virtual machines that cannot install third-party software.
Overview of OCR Function
The OCR function supports multiple languages, including Arabic, French, Russian, and Chinese, with additional packages available for download. We recommend using the Tesseract engine for the best results.
Setting Up the Script
To start, let’s manually write a function to launch the browser:
StartBrowser("CH", "https://wintask.net/demos-data/", 3)
The syntax StartBrowser
is followed by parameters to open Chrome maximized with the specified URL.
Capturing Text with OCR
1. Select the area where you want to capture text.
2. The OCR function will recognize and capture the text in the selected area.
Example syntax to capture text and display it in a message box:
ret = UseOCREngine(3)
var$ = CaptureAreaOCR$("CHROME.EXE|Chrome_WidgetWin_1|Data - Google Chrome",1, 959,340,26,122,"fra")
msgbox(var$)
Replace x, y, width, height
with the coordinates and dimensions of the area.
Additional Data Capture
If the text is not recognized initially, try selecting a larger area.
ret = UseOCREngine(3)
var$ = CaptureAreaOCR$("CHROME.EXE|Chrome_WidgetWin_1|Data - Google Chrome",1, 1569,115,34,107,"eng")
msgbox(var$)
Closing the Browser
To close the browser after running the automation, use the CloseBrowser
function:
CloseBrowser()
Running the Script
Execute your script to see the OCR function in action.
Conclusion
Thank you for following this tutorial on using WinTask’s OCR function. If you have any requests for future guides, please feel free to comment below.
Reference Code:
StartBrowser("CH","wintask.net/demos-data/",3)
ret = UseOCREngine(3)
var$ = CaptureAreaOCR$("CHROME.EXE|Chrome_WidgetWin_1|Data - Google Chrome",1, 959,340,26,122,"fra")
msgbox(var$)
ret = UseOCREngine(3)
var$ = CaptureAreaOCR$("CHROME.EXE|Chrome_WidgetWin_1|Data - Google Chrome",1, 1569,115,34,107,"eng")
msgbox(var$)
CloseBrowser()