Question #141369 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/141369
Status: Open => Answered
RaiMan proposed the following answer:
--- 2. loooooooong time
if you look through your solution, the following aspects might add to
"loooooooong time":
--- large region:
you use a relatively large region. If you are running on an average machine,
each find might cost you up to one second. So to speed up, restrict your search
to a smaller region.
e.g. I guess image "level_up" is in a specific area inside the app window:
buttonArea = Region(....)
if buttonArea.exists(level_up):
--- time cost of not found
you have 3 exists in your loop.
In the case, that none of them are found, it takes you about 10 seconds, before
the loop is repeated.
So when using exists to make decisions in the workflow and especially in a case
construct like yours, I always use exists(img, 0), since in this case it always
(found or not found) takes "only" one search try.
--- sequence of exists()
if you have some exists() on the same level (like in your case), the subsequent
exists are only visited, if the ones before fail. So (I do not know your game
logic :-) in your case it might last up to 20 seconds, before the second or
third exists() are executed successfully.
This normally is the situation, where observe() comes in, since the searches
are processed in parallel (wait for X 1.0rc2, before really trying it)
But there is an ugly looking, but working solution with exists():
while True:
case1 = False
case2 = False
case3 = False
if exists(imgCase1, 0): case1 = True
if exists(imgCase2, 0): case2 = True
if exists(imgCase3, 0): case3 = True
# you get here latest after 3 seconds
now you can play with your 3 cases and make some combined decisions like:
if case1 and not case2:
--- One more thing:
You are using:
with Region(0,40,1053,841):
this might be ok for testing purposes, but not for a "productive script"
;-)
look at the new features in the App class, that gives you the region of
an application window.
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.
_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to : [email protected]
Unsubscribe : https://launchpad.net/~sikuli-driver
More help : https://help.launchpad.net/ListHelp