Jump to content

Interception screen text


 Share

Recommended Posts

$dll_file = "TCaptureX.dll"
$Dll      = DllOpen("TCaptureX.dll")
$winhand=  WinGetHandle('')
$string  = DllCall($dll,"str","GetTextFromRect","hwnd", $winhand,"long",0,"long",0,"long",400,"long",400)
MsgBox(0,'info',$string)
DllClose($dll)

"GetTextFromRect" method captures the text from the rectangle specified (left, top,

width, height) in screen coordinates, in the window specified by hwnd.

But the above code, $string returns null

Link to comment
Share on other sites

Can you confirm that this "$winhand= WinGetHandle('')" causes the function to use the full desktop as its source.

HotKeySet("a", "testfunc")

$wTitle = "Notepad"

While 1
   Sleep(10)
wend

func testfunc()
    $ocr = _rectOCR($wTitle,0,0,200,200)
    MsgBox(0,"OCR", $ocr)
EndFunc

Func _rectOCR($wTitle, $rX, $rY, $rWidth, $rHeight)
    $xy = WinGetPos($wTitle)
    $Title = WinGetTitle($wTitle)
    $hwnd = Dec(StringTrimLeft(WinGetHandle($Title), 2))
    $obj = ObjCreate("TCaptureX.TextCaptureX")
    $results = $obj.GetTextFromRect($hwnd, $xy[0]+$rX, $xy[1]+$rY, $rWidth, $rHeight)
    return $results
EndFunc

This code still can not get the right result, I really need help

Link to comment
Share on other sites

Add this line to top of script,

Opt("WinTitleMatchMode",  2)      ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to  -4=Nocase

This helps?

edit: Ya, what he said..

Thank you, now you can extract the text in Notepad, but still can not extract the text in IE
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...