sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #17141
Re: [Question #224927]: i need to make my script faster and smarter!!
Question #224927 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/224927
Status: Open => Answered
RaiMan proposed the following answer:
this is my optimized version without knowing the visual workflow:
while exists("1363880501079.png", 20):
click( getLastMatch(), 0)
wait(10)
if exists(Pattern("1363668269597.png").similar(0.80), 10):
click(getLastMatch())
wait(10)
click(Pattern("1363668269597.png").similar(0.81))
if exists(Pattern("eaHnfowI.png").similar(0.81), 15):
doubleClick(getLastMatch())
#wait(15) not necessary see comment
if exists(Pattern("eaHnfowI.png").similar(0.80), 15):
doubleClick(Pattern("eaHnfowI.png").similar(0.80))
#wait(15) not necessary see comment
if exists(Pattern("Enter.png").similar(0.80), 15):
doubleClick(getLastMatch())
#wait(15) not necessary see comment
if exists(Pattern("Enter.png").similar(0.80), 15):
doubleClick(getLastMatch())
#wait(15) put in next click
click(wait("1363668856359.png", 15))
continue # starts at the while again 1st line
#**START OVER AT BEGINNING OF CODE**
restart = False
if exists(Pattern("1363919377569.png").similar(0.80)):
click( getLastMatch())
if exists("1363674112299.png", 0):
sleep(1800) # really meant to wait 30 minutes here?
restart = True
if exists("1363880884438.png", 20):
click("1363667165970-2.png")
#wait(10) put in next click
click(wait("1363668856359.png", 10))
restart = False
else:
restart = True
if restart:
rightClick("1363664789593.png")
click("Rastart.png")
while exists("RageofBahamu.png",40):
click( getLastMatch(), 0)
while exists("C10IDG00gIPI.png", 70):
click("N0Thlk5.png", 0)
a zipped version of the jasonlo.sikuli: https://dl.dropbox.com/u/42895525/jasonlo.sikuli.zip
but without the images ;-)
*** comments
- I have harmonized the indents (4 spaces) to be compatible with tab/shift-tab in the IDE
- the sequence
wait(secs)
if exists(image, secs):
does only make sense., if you really want to wait a fixed time secs
before starting the following search. But I guess, you did not mean
that, so only if exists(image, secs): is sufficient.
- continue
... can be used, to start a while loop all over again from somewhere inside.
But this only restarts the most inner loop: this is why the second continue case has to be revised by you, since I could not find out, from where you want to start all over (from inside the second while or after the 2 whiles: I decided for the second case)
Furthermore I put the duplicate code outside and used the variable restart, to decide wether it has to be processed before starting all over again.
Hope, I gave you some things to increase your Sikuli scripting
knowledge.
If you need more help, It is easier for me, to get your zipped .sikuli.
mail it silently to my mail at https://launchpad.net/~raimund-hocke
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.