Jump to content

Search the Community

Showing results for tags 'mirect'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. I saw a forum question that asked how to OCR non selectable text from a screen and get its coordinates. This intrigued me, as I would like to have this ability in my scripts. I found the following VB code and I am having difficulty "Converting" it to Autoit code. It provides a pixel count to a rectangle around a specified word relative to the window it is in. Sub TestRects() Dim miSelectRectDoc As MODI.Document Dim miSelectRectWord As MODI.Word Dim miSelectRectRects As MODI.MiRects Dim miSelectRectRect As MODI.MiRect Dim strRectInfo As String ' Load an existing TIFF file. Set miSelectRectDoc = New MODI.Document miSelectRectDoc.Create "C:\document1.tif" ' Perform OCR. miSelectRectDoc.Images(0).OCR ' Retrieve and display bounding rectangle information. Set miSelectRectRects = miSelectRectDoc.Images(0).Layout.Words(2).Rects strRectInfo = "Word falls within " & miSelectRectRects.Count & _ " bounding rectangle(s)." & vbCrLf For Each miSelectRectRect In miSelectRectRects strRectInfo = strRectInfo & _ " Rectangle coordinates: " & vbCrLf & _ " - Left: " & miSelectRectRect.Left & vbCrLf & _ " - Right: " & miSelectRectRect.Right & vbCrLf & _ " - Top: " & miSelectRectRect.Top & vbCrLf & _ " - Bottom: " & miSelectRectRect.Bottom Next MsgBox strRectInfo, vbInformation + vbOKOnly, _ "Rectangle Information" Set miSelectRectRect = Nothing Set miSelectRectRects = Nothing Set miSelectRectWord = Nothing Set miSelectRectDoc = Nothing End Sub I already have an OCR function that closely resembles this code. I would like to insert just the MiRect function into it. I get an error when attempting to create the MiRect and MiRects objects: Func OCR_Region($x,$y,$width,$height) ;note $height is NOT the height, it is the Y coordinate bottom right corner, width is bottom right corner X. Dim $miDoc, $Doc Dim $str Dim $oWord Dim $sArray[200] Dim $oMyError Dim $HexNumber Dim $msg Dim $i ;Const $miLANG_CZECH = 5 ;Const $miLANG_DANISH = 6 ;Const $miLANG_DUTCH = 19 Const $miLANG_ENGLISH = 9 ;Const $miLANG_FINNISH = 11 ;Const $miLANG_FRENCH = 12 ;Const $miLANG_GERMAN = 7 ;Const $miLANG_GREEK = 8 ;Const $miLANG_HUNGARIAN = 14 ;Const $miLANG_ITALIAN = 16 ;Const $miLANG_JAPANESE = 17 ;Const $miLANG_KOREAN = 18 ;Const $miLANG_NORWEGIAN = 20 ;Const $miLANG_POLISH = 21 ;Const $miLANG_PORTUGUESE = 22 ;Const $miLANG_RUSSIAN = 25 ;Const $miLANG_SPANISH = 10 ;Const $miLANG_SWEDISH = 29 ;Const $miLANG_TURKISH = 31 ;Const $miLANG_SYSDEFAULT = 2048 ;Const $miLANG_CHINESE_SIMPLIFIED = 2052 ;Const $miLANG_CHINESE_TRADITIONAL = 1028 Local $hBitmap1,$hImage1,$temp $temp=@ScriptDir & "\temp.bmp" _GDIPlus_Startup () ; Capture screen region $hBitmap1 = _ScreenCapture_Capture ("",$x, $y, $width, $height, False) $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap1) _GDIPlus_ImageSaveToFile ($hImage1, $temp) _GDIPlus_ImageDispose ($hImage1) _WinAPI_DeleteObject ($hBitmap1) $miDoc = ObjCreate("MODI.Document") ;=============================================================================== ;These two statements added for the MiRect function, they both produce an error $miSelectRectRects = ObjCreate("MODI.MiRects") $miSelectRectRect = ObjCreate("MODI.MiRect") ;============================================================================== $miDoc.Create($temp) ;MsgBox(0,"",$temp) ;this is the bitmap image which is "temp.bmp" $miDoc.Ocr($miLANG_ENGLISH, True, False) ;=============================================================================== ;These two statements added for the MiRect function, neither produce an error $miSelectRectRects = $miDoc.Images(0).Layout.Words(1).Rects $Left=$miSelectRectRects.count ;I don need ".Count", but it does something ;============================================================================== $i = 0 For $oWord in $miDoc.Images(0).Layout.Words $str = $str & $oWord.text & @CrLf ;ConsoleWrite($oWord.text & @CRLF) $sArray [$i] = $oWord.text $i += 1 Next FileDelete($temp) Return $sArray EndFunc Thanks for your help
×
×
  • Create New...