← Back to team overview

sikuli-driver team mailing list archive

[Question #694538]: Update of lastMatch after wait() in imported function

 

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

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."


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