sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #09357
Re: [Question #190541]: Observer running in the background, closing dialogs on popup
Question #190541 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/190541
Status: Open => Answered
RaiMan proposed the following answer:
--- parallel or sequentially?
first you have to decide, wether the images should be observed in parallel or sequentially. In the first case, you need one observer (and because one region can only have one observer) and one region per image. In the latter case you can define as many (theoretically ;-) events onXXX per region.
--- whole screen or region
to boost performance it is always a good idea, to restrict the search region so it is not the whole screen (each search in average takes about on second).
--- case parallel
# we use a dictionary, the regions have to be different objects!
a = {region1 : image1, region2 : image2, region3 : image3, region4 : image4}
def myHandler(event):
event.region.nearby(100).click(cross) # guess it is the close "button"
print "it happened"
# each image is observed in its own region
for r in a:
r.onAppear(a{r})
r.observe(FOREVER, background = True)
--- case sequentially
# we use a list
a = (image1, image2, image3, image4)
def myHandler(event):
event.region.nearby(100).click(cross) # guess it is the close "button"
print "it happened"
# each image is observed in its own region
r = Region(some_region)
for i in a:
r.onAppear(a[i])
r.observe(FOREVER, background = True)
--- How to make sure that the main script will not terminate/continue before the handler finishes closing the dialogs?
principally you can use one or more global variables to communicate between the handlers and the main script.
easier to script is to use Sikulis Settings class:
Settings.myVariable = False
this can be used everywhere without any additional actions.
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.