Capture Text From Image

How to Capture the text from a varying image in QTP?

Questions by sarita.sawant   answers by sarita.sawant

Showing Answers 1 - 9 of 9 Answers

GetTextLocation example
hwnd = Window("Microsoft Office Picture").WinObject("OIS Collection
Window").GetROProperty("hWnd") l = -1 'left
t = -1 'top
r = -1 'right
b = -1 'bottom succeeded = TextUtil.GetTextLocation("MASSACHUSETTS",hwnd,l,t,r,b)
If Succeeded Then
MsgBox "Text found"
End If

Thank you very much mukesh.
It solves my problem.
Just making your code more understandable by adding some notes.

GetTextLocation example:

hWnd is number which is "The handle to a run-time object's window".

Notes:
  • If hWnd is not 0, then the coordinate arguments apply to the specified window. If hWnd is 0, the coordinates apply to the screen.
  • The value 0 is not supported when running steps on Vista or on any 64-bit operating system.
As we don't know hWnd is zero or non-zero we can handle this condition as below
mentioned.

hWnd= Window("Microsoft Office Picture").WinObject("OIS Collection Window").GetROProperty("hWnd")

l= -1 'left
t= -1 'top
r= -1 'right
b= -1 'bottom

'Set all coordinates to -1 to search for the text string within the entire window or 'screen. The method returns the coordinates of the rectangle containing the first 'instance of the text into these variables if the text is found.

succeeded= TextUtil.GetTextLocation("MASSACHUSETTS", hwnd,-1,-1,-1,-1)

If Succeeded Then
MsgBox "Text found"

Else
MsgBox "Text not found"

End If

Thanks & regards
Anchal vaish

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions