← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #202284]: Some General Help For a New Learner :)

 

Question #202284 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/202284

RaiMan proposed the following answer:
--- the whole script would stop after the 30 second time out, right?
no ;-)

This is a speciality of Python: indentation
Where other programming/scripting languages use some kind of bracketing Python uses indentation, to show, which of the following statements belong to a block like while, if, else def, class, .... (see faq 1800 to avoid traps for newbees)

so some more buzz with the above example:

max = 5*60 # 5 minutes in seconds
start = time.time(); # now
# loop: 
while (time.time() - start) < max: # loop 5 minutes
    if exists(<image>, 30): # wait max 30seconds for image
        click(getLastMatch()) # click it
        wait(20) # wait 20 secs
    # end-if, skip else
    else: # did not come within 30 seconds
        click(<image1>)
    # end-else
    # end if-else
# end-while go back to loop
# AFTER while loop because same indent
print("you will see me after 5 minutes")

on looping see faq 1437

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