Friday, May 7, 2010

How to check text displayed in a image

Use "GetTextLocation" method to Checks whether a specified text string is contained in a specified window area. If the text string is located, the location coordinates are also returned.

TextUtil.GetTextLocation(TextToFind, hWnd, Left, Top, Right, Bottom[, MatchWholeWords])

TextToFind : The text string you want to locate
hWnd : The handle to a run-time object's window(If hWnd is not 0, then the coordinate arguments apply to the specified window. If hWnd is 0, the coordinates apply to the screen.)
Left, Top, Right, Bottom : These arguments define the search area within the window or screen. 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.

MatchWholeWordOnly : Optional. If True, the method searches for occurrences that are whole words only and not part of a larger word. If False, the method does not restrict the results to occurrences that are whole words only.
Default value = True

Script:

l = -1
t = -1
r = -1
b = -1

Succeeded = TextUtil.GetTextLocation("your search text",0,l,t,r,b)
msgbox Succeeded

No comments: