If you are just wanting to drag a rectangle and then OCR on that area, it is really not that hard.
Here is a simple SelectScreeenRegion function that feeds the area selected into OCR.
Code: Select all
#Requires AutoHotkey v2
; Select Screen Region with Mouse
^#LButton:: ; Control+Win+Left Mouse to Select
{
Area := SelectScreenRegion("LButton")
Result := OCR.FromRect(Area.X, Area.Y, Area.W, Area.H)
MsgBox(Result.Text)
}
Esc:: ExitApp
SelectScreenRegion(Key, Color := "Lime", Transparent:= 80)
{
CoordMode("Mouse", "Screen")
MouseGetPos(&sX, &sY)
ssrGui := Gui("+AlwaysOnTop -caption +Border +ToolWindow +LastFound -DPIScale")
WinSetTransparent(Transparent)
ssrGui.BackColor := Color
Loop
{
Sleep 10
MouseGetPos(&eX, &eY)
W := Abs(sX - eX), H := Abs(sY - eY)
X := Min(sX, eX), Y := Min(sY, eY)
ssrGui.Show("x" X " y" Y " w" W " h" H)
} Until !GetKeyState(Key, "p")
ssrGui.Destroy()
Return { X: X, Y: Y, W: W, H: H, X2: X + W, Y2: Y + H }
}
FG