Remove specific item from screen captures

Asked by Maurice Richard on 2017-03-02

Currently I have users selecting random values from a dropdown list.
I then have Sikuli take a screenshot of their selection. This works fine.

All values they can choose from have "Level 1" at the end of them.
I need to remove this from the captured screenshot.

Example values:
The quick brown - Level 1
The quick brown fox jumped - Level 1
The quick brown fox jumped over the - Level 1
The quick brown fox jumped over the lazy dogs - Level 1

Desired screenshot results:
The quick brown
The quick brown fox jumped
The quick brown fox jumped over the
The quick brown fox jumped over the lazy dogs

I'm currently using this code to capture the dropdown list selection.
CapturedValue = capture(332,454,275,13)

So I need to remove "Level 1" and everything after it on any given screenshot.

Any help is really appreciated!

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
Maurice Richard
Solved:
2017-03-02
Last query:
2017-03-02
Last reply:
Maurice Richard (flashfires) said : #1

I got this figured out.

The trick is to find "Level 1" and prevent it from going in the original screenshot.
By taking a screenshot of it, and finding its X coordinate, you can remove it dynamically.

    #Get the location of Level 1 for x,y calculations
    level = find("Level_1.png")

    #Get the selected image without the pesky "Level 1"
    #Subtracting X from Level1 image from X of original image(332), we get the new length
    captured_screen = capture(332,454,level.x-332,13)