Jump to content

DLLCall TCaptureX.dll


Recommended Posts

Here is a function I created and am using.

$ocr = _rectOCR("notepad",0,0,200,200)
MsgBox(0,"OCR", $ocr)

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
Link to comment
Share on other sites

Thanks a lot for posting this. I had just discovered rAutoIt when I ran into the limitation regarding interacting with non-standard MS-controls. Calling textcaptureX using your function seems an excellent workaround. ;)

In the code below I am trying to read a control directly. in the application that i am currently working with i had to introduce some offset variables.

The autoit window info tool shows the discrepancy of the y-offset also (a difference between x,y coordinates of "control under mouse" and "mouse detail").

The autoit window info tool does not show a discrepancy that would account for the need for the x-offset, so i had to experiment, but seem to have got it to work for my current application. (If somebody can shed some light onto this , that would be great).

Global $TextCaptureXoffset = 10, $TextCaptureYoffset = 30
Global $TextCaptureListViewXoffset = -4, $TextCaptureListViewYoffset = 46
$ocr = _ctrlOCR("Add selection","SysListView321")

MsgBox(0,"OCR", $ocr)


Func _ctrlOCR($wTitle, $sClassNameNN)

    $xy = WinGetPos($wTitle) 
    $ctrlXY = ControlGetPos($wTitle,"",$sClassNameNN) 

    $Title = WinGetTitle($wTitle)
    $hwnd = Dec(StringTrimLeft(WinGetHandle($Title), 2))
    $obj = ObjCreate("TCaptureX.TextCaptureX")

    if StringInStr($sClassNameNN,"SysListView32") <> 0 then
        $results = $obj.GetTextFromRect($hwnd, $TextCaptureListViewXoffset + $xy[0]+$ctrlXY[0], $TextCaptureListViewYoffset + $xy[1]+$ctrlXY[1] , $ctrlXY[2], $ctrlXY[3])
    else
        $results = $obj.GetTextFromRect($hwnd, $TextCaptureXoffset + $xy[0]+$ctrlXY[0], $TextCaptureYoffset + $xy[1]+$ctrlXY[1] , $ctrlXY[2], $ctrlXY[3])
    endif

    return $results
EndFunc
Edited by vtr
Link to comment
Share on other sites

Trying to reproduce what has been accomplished in this thread, I keep bumping into the following error:

C:\Documents and Settings\Chef\Desktop\test\New AutoIt v3 Script.au3 (19) : ==> Variable must be of type "Object".:

$results = $obj.GetTextFromRect($hwnd, $xy[0]+$rX, $xy[1]+$rY, $rWidth, $rHeight)

$results = $obj^ ERROR

?

How can I fix that? Thanks in advance

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
Link to comment
Share on other sites

  • 1 year later...

WinMove("Senza nome - Blocco note", "", 0, 0)
$ocr = _rectOCR("Senza nome - Blocco note",0,0,200,200)
MsgBox(0,"OCR", $ocr)

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

im getting Variable must be of type Object, any solution?

I will appreciate any help

Ty

Giovanni

Link to comment
Share on other sites

  • Moderators

up

Please do not resurrect 2 year old posts. If you have a question or a concern, you need to start your own thread.

Look at IsObj() in the help file and wrap $results = $obj.GetTextFromRect($hwnd, $xy[0]+$rX, $xy[1]+$rY, $rWidth, $rHeight) in a conditional If/Then statement.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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...