sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #03976
Re: [Question #164956]: i am unable to take sikuli from 1 condition to another
Question #164956 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/164956
Status: Open => Answered
RaiMan proposed the following answer:
your workflow seems to be:
-- block1: repeat block2 to block4 400 times
-- block2: if condition1 is met do task1
-- block3: else (if condition1 is not met) do task2
-- block4: then (after either task1 or task2 is done) do task3
In Sikuli (Python) pseudo syntax:
for m in range(400): # starts block1
<indent>if condition1: #starts block2
<indent><indent>statements of task1
<indent>else: #starts block3
<indent><indent>statements of task2
<indent>statements of task3
print "finished" # first statement after block1
the magic is indentation: to show, that statements are belonging to a block
(that starts with if/elif/else/for/while/def/class/try/except ...)
all the statements must have the same indentation level and one level more, than the block start statement.
This can easily (this is the recommendation) be accomplished in Sikuli-
IDE by using one tab for one indent (<indent> above) and one shift-tab
for one dedent with the next statement after the block (or one tab less
than the last statement belonging to the block).
Behind the scenes: one tab inserts 4 blanks at the beginning of the
statement and one shift-tab deletes 4 blanks at the beginning of the
statement.
So if you ever get a situation, where indentation is a problem:
select all lines that might be affected and use shift-tab until all lines are left justified. then top down select the blocks of statements, that need the same indentation and tab as needed.
so in your example:
for m in range(400):
<indent>if exists ( ): -------------> 1 condition
<indent><indent>click( )
<indent>else:
<indent><indent>click( )-------------------------condition over
<indent>sleep(4)
<indent>rightClick( )---------------------->2 tasks start here
<indent>sleep(20)
<indent>click( )
<indent>sleep(2)
<indent>click( )
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.