Highlight Images

Asked by Eric G on 2020-03-24

I would like to highlight certain images whenever they present on the screen. I know I can do reg.highlight, but I'm having trouble highlighting the actual image matches. Is there a way I can use something like reg.getLastMatch but instead of click or hover make it highlight?

I've tried stuff like:

reg= Region(0,0,1366,103)
if reg.exists([imm1.PNG, imm2.PNG, imm3.PNG, etc], 0):
     reg.getLastMatch(highlight(1))
##this highlights my entire screen

also tried

test=[imm1.PNG, imm2.PNG, imm3.PNG, etc]
matches=reg.findAny[test]
if matches:
    matches.highlight(1)
##doesnt work

Basically Im trying to make something like
while True:
     find(imm1.PNG):
          match.highlight
##fails when imms not visible also only highlights 1 imm at a time

but for multiple images at the same time and in a loop.

Any ideas? I've read the docs but I only learned how to highlight regions

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
2020-03-25
Last query:
2020-03-25
Last reply:
2020-03-25
Eric G (gamemaster181) said : #1

So apparently I got the highlighting to work on multiple images, but is there any way that I can highlight them at the same time? As in have 3 or 4 highlighted items at once? Currently, I just cycle through them with a for loop.

##^rest of code
if selected == Comps[3]:
    while True:
        matches = reg.findAny(test)
        for match in matches:
            match.highlight(1)

Best RaiMan (raimund-hocke) said : #2

--- if reg.exists([imm1.PNG, imm2.PNG, imm3.PNG, etc], 0):

not possible - only one image as parameter allowed

--- second trial (see docs!)

test=[imm1.PNG, imm2.PNG, imm3.PNG, etc]
matches=reg.findAnyList(test)
for match in matches:
    match.highlight(1)

The solution: (see docs!)

for match in matches:
    match.highlightOn()
wait(1)
highlightAllOff()

Eric G (gamemaster181) said : #3

Thanks RaiMan, that solved my question.