Order of matches / image scan

Asked by Pathiyil

Hi,

Based on the response to https://answers.launchpad.net/sikuli/+question/151831 , I guess there is no guaranteed order of scanning images in a screen ? I tried it out by littering my screen with a few Chrome images and click(), did select different images in different iterations.

Mostly out of curiosity - is there a reason for this ? Doesn't the scan always start at (0,0) or top left corner of the specified region and then work left-to-right top-to-bottom order ?

Thanks.

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
RaiMan Edit question
Last query:
Last reply:
Revision history for this message
obiwan-92 (obiwan-92) said :
#1

Hello,

It's probably because there is no need to slow down the function for something, we can perfectly do our-self.

Try this :
for item in sorted(findAll("img.png"), key=lambda m:m.y):
    print item

You will find every information here :
http://doc.sikuli.org/region.html#finding-inside-a-region-and-waiting-for-a-visual-event

Regards.

Revision history for this message
Pathiyil (pathiyil) said :
#2

Hi obiwan,

Thanks for the response. My question was indeed to know if always starting from (0,0) was considered sub-optimal - was there an optimization like "most probably the next click/find will be for an item below the current one, so lets start the search from here...".. Again, asking purely from an interest to know the internals..

Revision history for this message
RaiMan (raimund-hocke) said :
#3

every new find (or the implicit find in a new click) will always search in the given region (might be the screen).
So you most probably get the same matches again.

If you want a different behavior, you have to define a restricting region, based on the last match, that you want to exclude from further finds.

But sounds like an interesting idea: it should be checked (I will do that), wether we can define regions to be searched, that contain "no-go-areas", which would allow to repeat the same find on the same region, after having "subtracted" the area containing the last match.
Which corresponds with another request, that wants to find with an image, where parts are excluded from the image (e.g. some inner part containing text, that might change (localized buttons)).

Can you help with this problem?

Provide an answer of your own, or ask Pathiyil for more information if necessary.

To post a message you must log in.