← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #194144]: How to make exists(img, 0.01) return immediately even if it fails --- solution: Settings.WaitScanRate

 

Question #194144 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/194144

RaiMan posted a new comment:
--- WinXP being different from Win7 emulated
This is the internal logic for the basic search operation:
- load the given image from the image path
- if the file is not found, take string as text and try to search for that using OCR (with error log message)
- start a timer
- evaluate max waiting time (standard or given value)
- evaluate WaitScanRate: 1 Second / WaitScanRate => minimum time to elapse until next search is started after the start of the last one (standard: 1 / 0.3 = 0.3333 seconds)
- make one search trial
- if found go back to caller returning match
- if not found check max waiting time reached, if yes, return to caller (might give FindFailed exception)
- if not found, wait until minimum search elapsed time is reached and start next search

This is totally written at the Java level and is definitely the same on
Win XP and Win 7, emulated or not.

I will post a request bug: when using a wait time that is smaller than the step timing based on the WaitScanRate when using exists, it should return after the given duration, even if the pattern is not found.
This makes sense, since exists() is mostly used in decision situations, where you might want the same timing, no matter wether it is found or not and independently from current WaitScanRate.

--- Just hope the extra overhead doesn't crash the applications being watched
this could easily be fixed for your situation:

instead of using
exists(image, 0)

make the following def:

def fastExists(image, wait, reg = SCREEN):
    wsr = Settings.WaitScanRate
    Settings.WaitScanRate = 100
    m = reg.exists(image, wait)
    Settings.WaitScanRate = wsr
    return m

and use it
if fastExists(image, 0):
....

So the the high scan rate is exclusive for the fastExists and in fact
does not matter, since in this case it is searched only once anyway.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.