pippi Posted November 16, 2006 Share Posted November 16, 2006 Is it standard window font or is it graphic font? (makes a difference)I tried it with notepad and Firefox. Link to comment Share on other sites More sharing options...
pippi Posted November 16, 2006 Share Posted November 16, 2006 Is the script i posted working for you? Link to comment Share on other sites More sharing options...
CyberGlitch Posted November 23, 2006 Author Share Posted November 23, 2006 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 More sharing options...
vtr Posted November 23, 2006 Share Posted November 23, 2006 (edited) 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 November 23, 2006 by vtr Link to comment Share on other sites More sharing options...
Sven Posted November 27, 2006 Share Posted November 27, 2006 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 More sharing options...
lavezzi Posted September 5, 2008 Share Posted September 5, 2008 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 More sharing options...
lavezzi Posted September 7, 2008 Share Posted September 7, 2008 up Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 7, 2008 Moderators Share Posted September 7, 2008 upPlease 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now