Technical support and scripting issues
Moderators: Dorian (MJT support), JRL
-
psiquetp
- Junior Coder
- Posts: 25
- Joined: Tue Jul 17, 2018 7:56 pm
Post
by psiquetp » Fri Jul 27, 2018 5:36 am
The TextCaptureWizard is able to show me some text, but once the inserted code is executed by the macro... it is not working anymore... maybe there is something I'm missing that can make a difference
This is the inserted code
Code: Select all
GetTextInit
GetTextAtPoint>605,645,result,c
MessageModal>result
In the wizard it shows me a lot of text
Code: Select all
4500035203 490 PER SAC USD 3,685.63 3,685.63 0.00 3,685.63 0.00
but the inserted shows an empty modal once executed.
Please help, I have not being able to make any progress on this window... OCR is failing as well.
Thanks!
-
Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
-
Contact:
Post
by Marcus Tettmar » Fri Jul 27, 2018 1:20 pm
The only thing I can think of is that the wizard is calling the function in a loop - so that the output is continually updated. These functions have to monitor the Windows text out functions. It's possible that at the moment your script makes a request and "hooks in" the Text Out functions aren't reporting anything. So you could try putting it into a loop and see if that gets you anything, looping until you do:
Code: Select all
GetTextInit
Let>result={""}
While>result={""}
GetTextAtPoint>605,645,result,c
Wait>0.02
EndWhile
MessageModal>result
If this works I'd recommend adding in a timeout, to avoid an infinite loop if it never finds anything. But for testing, try it.
-
psiquetp
- Junior Coder
- Posts: 25
- Joined: Tue Jul 17, 2018 7:56 pm
Post
by psiquetp » Sat Jul 28, 2018 6:15 am
It worked like a charm.
Thank you!
Code: Select all
//Subroutine to the text found in a given area ------------------------------------------
//Const: BASE_DIRECTORY .- Directory where the macro has its files.
//Const: IMAGES_SUB_DIRECTORY .- Directory inside the BASE_DIRECTORY where the macro has the images to be searched for.
//Input: NEW_IMAGE_FILE_NAME .- Name of the file to store an image of the area in the WORK_DIRECTORY.
//Input: X_CORD,X2_CORD .- Horizontal coordinates of the area where the text is supposed to be.
//Input: Y_CORD,Y2_CORD .- Vertical coordinates of the area where the text is supposed to be.
//Input: SEARCH_MAX_ATTEMPTS .- (Optional) Attempts to be done at finding the text.
//Outpt: STR_OCR_RESULT .- The text found. The string ERR if nothing was found.
SRT>RecognizeTextInArea
GetCursorPos>nXPos,nYPos,csType
GoSub>CalculateCoordinatesCenter
ScreenCapture>X_CORD,Y_CORD,X2_CORD,Y2_CORD,%BASE_DIRECTORY%\%WORK_DIRECTORY%\%NEW_IMAGE_FILE_NAME%
Wait>1
Let>STR_OCR_RESULT={""}
OCRImage>%NEW_IMAGE_FILE_NAME%,STR_OCR_RESULT
Trim>%STR_OCR_RESULT%,STR_OCR_RESULT
If>STR_OCR_RESULT={"ERR"}
Let>STR_OCR_RESULT={""}
EndIf
//If OCR did not work try GetText
Let>COUNT_GET_TEXT=0
GetTextInit
While>STR_OCR_RESULT={""}
MouseMove>X_CORD,Y_CORD
Wait>0.2
MouseMove>X2_CORD,Y_CORD
Wait>0.2
MouseMove>X2_CORD,Y2_CORD
Wait>0.2
MouseMove>X_CORD,Y2_CORD
Wait>0.2
MouseMove>XC_CORD,YC_CORD
Wait>0.3
Let>STR_OCR_RESULT={""}
GetTextInRect>X_CORD,Y_CORD,X2_CORD,Y2_CORD,STR_OCR_RESULT
Trim>%STR_OCR_RESULT%,STR_OCR_RESULT
Let>COUNT_GET_TEXT={%COUNT_GET_TEXT% + 1}
If>STR_OCR_RESULT={"ERR"}
Let>STR_OCR_RESULT={""}
EndIf
If>%COUNT_GET_TEXT%>5
Let>STR_OCR_RESULT={"ERR"}
EndIf
EndWhile
MouseMove>nXPos,nYPos
END>RecognizeTextInArea