Jump to content

ScorpX

Members
  • Posts

    5
  • Joined

  • Last visited

ScorpX's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. This can be solved by setting this value to True $_HandleImgSearch_IsDebug = True
  2. the HandleCapture does not save images to the provided path. here is what i tried, it only returns a handle. ;~ #RequireAdmin #include <Array.au3> #include ".\HandleImgSearch.au3" Local $handle = WinGetHandle(0x001A0AEA) Local $x = 0 Local $y = 0 Local $width = 800 Local $height = 600 Local $isBMP = False Local $savePath = @ScriptDir & "\captured_image.bmp" Local $result = _HandleCapture($handle, $x, $y, $width, $height, $isBMP, $savePath, False) If @error Then MsgBox(16, "Error", "Capture failed. Error code: " & @error) Else MsgBox(64, "Success", "Capture successful. " & $result) EndIf
  3. if you want to move mouse to the location of the text and you found example 4 was complicated, then here is a simpler code example to let you move mouse to the location of text, change line 15 to the text you want. @Werty @CommZ3 maybe its not efficient but you don't have to use gdi+ if you don't know about it. a shorter code #include <ScreenCapture.au3> #include <UWPOCR.au3> _ScreenCapture_Capture(@ScriptDir & "\screenshot1.png", 0, 0, @DesktopWidth, @DesktopHeight) Local $aWords = _UWPOCR_GetWordsRectTo2DArray(@ScriptDir & "\screenshot1.png") Local $sTargetWord = "New" For $i = 0 To UBound($aWords) - 1 If $aWords[$i][0] = $sTargetWord Then MouseMove($aWords[$i][1] + $aWords[$i][3] / 2, $aWords[$i][2] + $aWords[$i][4] / 2) ExitLoop Next a longer code with explanation #include <ScreenCapture.au3> #include <UWPOCR.au3> ; Set the path and file name for the screenshot Local $sScreenshotPath = @ScriptDir & "\screenshot1.png" ; Capture a screenshot of the desktop and save it to a file _ScreenCapture_Capture($sScreenshotPath, 0, 0, @DesktopWidth, @DesktopHeight) ; Extract the text from the screenshot using UWPOCR Local $sText = _UWPOCR_GetText($sScreenshotPath) ; Set the target word to be searched Local $sTargetWord = "change_this_to_word_to_find" ; Look for the target word Local $aWords = _UWPOCR_GetWordsRectTo2DArray($sScreenshotPath) ; Loop through each word in the array For $i = 0 To UBound($aWords) - 1 ; If the word matches the target word If $aWords[$i][0] = $sTargetWord Then ; Calculate the center of the rectangle enclosing the word Local $iX = $aWords[$i][1] + $aWords[$i][3] / 2 Local $iY = $aWords[$i][2] + $aWords[$i][4] / 2 ; Move the mouse to the center of the rectangle MouseMove($iX, $iY) ; Exit the loop ExitLoop EndIf Next
  4. Hello, I'm wondering if it's possible to obtain the coordinates of text detected by this OCR. I have written a piece of code that captures a screenshot from an emulator and then uses this OCR to extract the text from that image. However, I am unsure how to retrieve the exact location or coordinates of the identified text. Could you please advise me on how to accomplish this task? also what am asking is possible, then what if there is multiple texts, how can i get the coordinates of a specified text. the coordinates should be relative to the image. if you have a better idea on how to do this, let me also do #include <UWPOCR.au3> Run("adb -s emulator-5554 shell screencap -p /storage/emulated/0/picz/screenshot.png", @SW_HIDE) Sleep(1000) Run("adb -s emulator-5554 pull /storage/emulated/0/picz/screenshot.png " & @ScriptDir & "\try.png", @SW_HIDE) Local $sOCRTextResult = _UWPOCR_GetText(@ScriptDir & "\try.png", Default, True) MsgBox(0, "OCR", $sOCRTextResult)
×
×
  • Create New...