Action upon NO change

Asked by Nidere

I've been googling for 4 hours, but haven't found a solution for my case, which is meant to be pretty simple:

Handler1
  Handler2
    action1
  IF region CHANGE then handler2
  ELSE action2
IF reg CHANGE then handler1
ELSE action 3

In other words I need to repeatedly do action1 while the region changes. If it stops changing, I try action2. If it still does not change I try action3.

Is there a way to put a handler inside a handler?

Sorry for bad explanation and thanks in advance!

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

Handler in handler: no.

A loop to detect that a region changes:
reg = ... some region
while True:
  img = Pattern(capture(reg)).exact() #1
  if reg.exists(img, 0): #2
    # no change
  else:
    # has changed
  wait(1)

Use break to jump out of the loop

#1 and #2 are the way to check for changes in the region reg

Sorry for answering briefly: I am on vacation :-)

Revision history for this message
Nidere (nidere) said :
#2

Thanks alot, RaiMan!
Rest well)

Revision history for this message
Nidere (nidere) said :
#3

Thanks RaiMan, that solved my question.