@GkenvinOD: If you manage to optimize it to less than a second it would be a very valuable function (100% accuracy, independent of tesseract, image files,...). If you need any assisstance I'm happy to help 🙂
@AtoZ: Yes when I first started I wasn't fully familiar with coord, pixel mode so every coordinate and color value was hand-picked using a custom script to output value (in that script coord mode was set to 2). The difference between mode 0 and mode 2 is (0,21) as the height of Windows Active Title Bar is 21 (Windows default). It doesn't matter which one though, but I will look through the code again to ensure consistency. Also you can try GkevinOD's code again with $x and $y change to +52 and +93. It's very accurate but very picky about getting first pixel correct.
Problems regarding the ReadValue function is caused by missing Tesseract or traineddata as odySSeys says. If there's no Tesseract or traineddata, $Read value will return null which will fail the check, causing it to stuck in a loop (without the check insufficient data will crash the program). Here's how to make sure it works:
- Download Tesseract-OCR.rar from this link: http://www42.zippyshare.com/v/41826460/file.html
- Inside the folder is tesseract.exe, traineddata, configs folder and Tesseract.au3 (this is Autoit UDF to interact with Tesseract)
- Unrar and place the main script in the same folder, make sure it is #include "Tesseract-OCR\Tesseract.au3" in the script.
The main script will call Tesseract.au3, Tesseract.au3 will call tesseract.exe via ShellExecuteWait (path\to\tesseract.exe)
Simple script to test if Tesseract works:
#include "Tesseract-OCR\Tesseract.au3"
Opt ("MouseCoordMode", 0)
$Title = "BlueStacks App Player"
$Full = WinGetTitle ($Title)
$HWnD = WinGetHandle ($Full)
WinActivate ($HWnD)
Global $Left = 54
Global $Top = 81
Global $Right = 745
Global $Bottom = 555
$Read = _TesseractWinCapture($HWnD,"",0,"",1,2,$Left,$Top,$Right,$Bottom,1)