Clicking check boxes based on text

I am trying to create a generic handler for selecting a checkbox. But by Generic I mean it’s able to pick it based on the next next to the check box. Like a row of check boxes that say “Option 1, option 2 , Option 3” with the checkbox a little to the left of the text and the three options placed in a column.

The below code errors imagefound Error - Invalid Rectangle: MySearchRect (its saying it either cant find the rectangle or the coordinates are not right or not valid

To handle SelectBox

params Check_Name

Set SearchRectangle to my QueryPaneSRC

set the TextLocation to ImageRectangle (text:(Check_Name))

set Check_Name to (left to TextLocation – 35, right of TextLocation, top of TextLocation – 3, right of the RemoteScreenRectangle, the bottom of TextLocation + 2)

put MySearchRect

If ImageFound(ImageName:”Images/Box_UNCHECKED”, searchRectangle: MySearchRect

 Then

     Click FoundImageLocation()

  Return

Else

 ImageFound(ImageName:”Images/Box_CHECKED”, searchRectangle: MySearchRect

 Return

End if

End SelectBox

Run SelectBox ”Option 1”

Hi Metazoxan,
in general I would implement such things as object (eggplant is an OO Language). Thus you get objects Option1, Option2, Option3 etc all of them of type “Checkbox”. Methods for those checkboxes collected in a Checkbox helper suite, where you define your Set, Unset, Check methods.
But let’s focus on the simple technical issue. You have two options - either to search the text 1st and then the checkbox image or the checkbox 1st and the text after.
Variant 1: Is preferred , when used on browser windows. Use typetext controlKey,“f” and typetext “Option 1”. The found text will be highligthed. So you can search an image, with a highligthed text with a neighborgh checkbox (possibly a collection). Edit these images to cut out the text itself. This option is not suffering from OCR errors. No cycles and automatic scroll on the screen.
Varian 2: Use checkbox images (collection) including partly the text. Edit the images to cut out the text, but set the location to the beginning of the text. Now you can build a set of locations set chkBoxLocs to EveryImageLocation(“checkbox”) and afterwards run a repeat loop with each item of chkBoxLocs. Inside the loop you do a ReadText(it) until the wanted text is matching.
There are plenty of opportunities. These are two of them. Hope it is helpful
BR

Your “MySearchRect” variable seems to be undefined.
Did you intend to set it like this?

set MySearchRect to (left to TextLocation – 35, right of TextLocation, top of TextLocation – 3, right of the RemoteScreenRectangle, the bottom of TextLocation + 2)

Hey there,

Why don’t you make use of a Dynamic Search Rectangle that can easily find the checkbox you need in a shorter period of time.

For Example
Click image:“Web Based Images/SCartCheckBox_Img”, searchrectangle:[[960, imagelocation(text:“I agree”).y-20], remotescreensize()]

The above mentioned DSR checks for a checkbox to the left of the name “I agree” using 960 as your starting corner point just above and to the left of the checkbox. Would make it so much easier.
Then modify the Text name to the option you want it to look for. (this is a simple direct way)

Or you can set a variable to help you
Click image:“chk_CheckBox”, searchrectangle:[[650, imagelocation(text:universal var_TimeStamp).y-20], remotescreensize()]

Dynamic search Rectangle is what I was going for. Will try out your suggestion

This is primary reason that the code is failing. Good catch.

Hi.
I am here looking for how can I add check boxes on the based of text, I want to add some check boxes on my website, I have tried many times to do and also search on the google but not found the good results. Need help regarding this how can I do this