← Back to team overview

sikuli-driver team mailing list archive

[Question #195342]: Optimal way to scan constantly in main loop

 

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

I'm trying to determine the most optimal way to scan for an image on the screen constantly and then perform an operation when found.

My application defs are all triggered by hotkeys so I have a main loop as:

while True:
    wait(1)


I add into my main loop code similar to the following:

while True:
    wait(1)
    Settings.ObserveScanRate = 0.2
    if TestEpisodeRegion.exists("nextepisode.png"):
        print("i see you")
    Settings.ObserveScanRate = 1 

I am not entirely sure what measurement the wait is being calculated at...is it seconds or ms?
Also, if I understand correctly a 0.2 scan rate will scan only about every 4-5 seconds?

My goal is to have the scan rate for all the hotkey events to function with a normal scan rate (3/second?) as I need quick response on those events, but the detection of the "nextepisode.png" I am willing to live with about a 5 second delay before it is pressed in order to minimize CPU usage.

Can you comment if my code is proper for the desired effect, or what I should modify?

thanks!

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