[2.0.4] lastMatch not updated using wait() in imported function

Asked by Matthias on 2020-12-16

I stumbled across an unexpected behaviour while using one Sikuli script as import in another Sikuli script and would like to know, if maybe I am doing it wrong.

This is the main script (foo.sikuli):
--------------------------------------------------

import bar
reload(bar)

bar.search()

--------------------------------------------------

This is the imported script (bar.sikuli):
---------------------------------------------------------

from sikuli import *

def search():
    click("img1.png")
    wait("img2.png")
    click(getLastMatch())

--------------------------------------------------------

My expectation was that "click(getLastMatch())" clicks on the position of img2.png. Instead, it clicks on the position of img1.png, as the log shows:

[log] CLICK on L[117,53]@S(0) (523 msec)
[log] CLICK on L[117,53]@S(0) (21 msec)

I found out that it works as expected if I use 'SCREEN.wait("img2.png")' instead:
---------------------------------------------
def search():
    click("img1.png")
    SCREEN.wait("img2.png")
    click(getLastMatch())
---------------------------------------------
[log] CLICK on L[117,53]@S(0) (525 msec)
[log] CLICK on L[1448,395]@S(0) (523 msec)
--------------------------------------------------------------------

But as SCREEN should be the default, could it be that the single "wait()" updates lastMatch in the wrong context? With "find()" it works with or without an explicit "SCREEN."

Question information

Language:
English Edit question
Status:
Answered
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2020-12-16
Last reply:
2020-12-16
RaiMan (raimund-hocke) said : #1

Thanks for documenting this behavior.

Supposing you are using 2.0.4

I have to check.

Can you help with this problem?

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

To post a message you must log in.