sikuli_cpython icon indicating copy to clipboard operation
sikuli_cpython copied to clipboard

wait function not working

Open evbo opened this issue 10 years ago • 4 comments

The wait function does not define the duration variable:

def wait(target_string, *args, **kwargs):
    if not duration and duration != 0:
        duration = 5000
    target = Pattern(target_string).getTarget()
    screen = DesktopScreenRegion()
    return screen.wait(target, duration)

Also, the Pattern().getTarget() crashes causing a jvm error.

evbo avatar May 19 '14 00:05 evbo

The problem is how ImageTarget gets constructed. So, to save it from crashing you need to pass it a URL (not relative image path like you do in sikuli IDE).

For instance, this works on my machine:

import sikuli as si
si.wait('file:///C:\\targetImage.png', 10)

evbo avatar May 19 '14 01:05 evbo

this doesn't solve for me:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Traceback (most recent call last):
  File "sikuli_nounittest.py", line 16, in <module>
    main()
  File "sikuli_nounittest.py", line 6, in main
    wait("file:///bla/bla/blabla/blabla/blablabla.png", 60)
  File "/usr/lib/python2.7/sikuli/sikuli.py", line 41, in wait
    if not duration and duration != 0:
UnboundLocalError: local variable 'duration' referenced before assignment

mnovait avatar Aug 19 '15 08:08 mnovait

submitted a patch for the wait function together with @mnovait

lucagiove avatar Aug 19 '15 09:08 lucagiove

actually noticed that some bugfix and improvements have been committed in a fork from @flycodepl https://github.com/flycodepl/sikuli_cpython. I already asked via mail if he could submit a pullrequest

lucagiove avatar Aug 19 '15 16:08 lucagiove