← Back to team overview

sikuli-driver team mailing list archive

[Question #665855]: SikulixIDE 1.1.2 - Would it be possible to optimize a long if/elsif/else loop with exists() inside?

 

New question #665855 on Sikuli:
https://answers.launchpad.net/sikuli/+question/665855

Hello, I have a long piece of code and I was wondering if it would be possible to optimise it so it goes faster. I have to check certain region of the screen constantly to see what appears in it. The problem is that it can appear up to 200 different things, so it needs to compare 200 different images with whatever is in the screen until it founds the right one, and it has do to something different in the screen with each one of the possible options. Right now, it does that just fine, but if the image that appears is the last one of the loop it needs around 25 seconds to match it, and I would like to know if it would be possible to reduce that time.

This is my code:

r = regionOfTheScreen
if r.inside().exists((Pattern(img1).exact()),0):
    #do something
elif r.inside().exists((Pattern(img2).exact()),0):
    #do something else

+198 elifs more with the same form.

Could I change something to make it faster? I already run it with only the necessary programs running on my computer and I check the smallest possible region of the screen. 

Thank you!

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.