How to loop Images Matches element to Scrape Relative

I am able to use Scrape Relative to get OCR text with successful result.

Now I want to use Images Matches and loop all UIElement to Scrape Relative.
I try to copy Scrape Relative sequence and paste into For Each activity of matched UIElement.
There is a problem, I don’t know how to Set Clip Region of each element, in order to get OCR text.

Hi @ccyfly

It would help if you could provide some screenshots for extra context. Imagining the situation is always easier and might get you the answer you want a bit faster :slight_smile:

Here is a sample what I want to accomplish.

In a word document, I want to capture text next to checkbox which is checked.

Here is a xaml file with two sequence.
One sequence is using “Scrape Relative” to get text.
Another one is using “Find Image Matches” to find all checked checkboxes. But I don’t know how to set clipping region correctly, in order to use OCR text next to checkbox.
WordCheckBox.xaml (23.1 KB)

I am looking for the same thing, UiPath please help?
we need to scrape an OCR Text relative to an UiElement :frowning:

I have been able to accomplish this by doing the following:

  1. Use Find Image Matches to find the checkbox image. The output of this will be an enumerable list of ui elements. For example, let’s call it “A”
  2. Setup a “For Each” action, setting the TypeArgument to “UiPath.Core.Element”. Now, set the For Each should be “for each ITEM in A”
  3. Within the For Each action, put a “Find Relative Element” action. Instead of using “Indicate on screen”, use the Target.Element property, and set it to “item” (from the For Each Item…")
  4. for the OffsetX property of the Find Relative Element action, set it to a number. This will be a number of pixels away from the first element. You can find this by downloading a “pixel ruler” tool. Basically what you’re saying is “How far away from the checkbox is the text I want”. You can set the “Position” property to be Top Right or Center or whatever area of the 1st element you want to measure from to find the 2nd element. Now, let’s name the output variable of the Find Relative Element to B.
  5. Use a Get Text action, and again, instead of using the “indicate element on screen” option, edit the properties of the Get Text action, and set the Element to “B” (or whatever name you chose for the output variable of the Find Relative Element action) Name the output variable of the Get Text action to C.
    So the basic layout of your actions is this:
  6. Find Image Matches (output = A)
  7. For each item in A (type argument setting = UiPath.Core.UIElement)
  8. FInd Relative Element (element setting = item, offsetx = distance in pixels from checkbox to text field, output = B)
  9. Get Text action (element setting = B, output = C)
  10. Finally, do a Writeline, set the text to variable C and you should see your text in the output!
1 Like