Observing Multiple Regions Simultaneously
Hello,
I'm trying to watch for one of any number of windows to appear. Previously, I simply observed for all of them on the entire screen:
imgOne = "imgOne.png"
imgTwo = "imgTwo.png"
imgThree = "imgThree.png"
onAppear(imgOne, handlerOne)
onAppear(imgTwo, handlerTwo)
onAppear(imgThree, handlerThree)
while (True):
Observe(
But, now I want the script to run faster, so I've cut down the regions that each window could appear in:
"""
imgOne = "img1.png"
imgTwo = "img2.png"
imgThree = "img3.png"
rOne = Region(0,0,200,200)
rTwo = Region(
rThree = Region(
rOne.onAppear(
rTwo.onAppear(
rThree.
"""
xloc = 0
for x in ["One", "Two", "Three"]:
img = "img" + x + ".png"
reg = Region(200*xloc, 0, 200, 200)
reg.
xloc++
While(True):
observe(
But, it seems like the call to Observe isn't working (for either of the methods above, the old way of hand coding each region, or the new dynamic one). I believe its because Observe only refers to events tied to the entire screen, and not to any specific region that has been created. But, the documentation isn't very deep on the subject. Ideally, I would like to be able to keep everything dynamic in the for loop, because I may want to add images later and it just makes for convenient code.
I tried calling observe on each region individually:
for reg in regs:
reg.
But its a blocking call, so only one image would be looked for at a time. Is there a way to observe multiple regions at one time, or do I need to switch the backbone to a loop of
while (True):
for img in imgs:
if (reg.exists(img)): handle(img)
? I'd rather not, Observe seems more elegant.
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- SikuliX Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Lebron Jones for more information if necessary.