[Sikuli-driver] [Question #268536]: image click on multiple appearances

2015-06-25 Thread Alias
New question #268536 on Sikuli:
https://answers.launchpad.net/sikuli/+question/268536

On the webpage that I'm trying to automate, there are three images in total 
that need to be clicked. First, an attack image. Second, a continue image. 
Third, a restart image. Sikuli should click the attack image, then move on to 
the continue image. Once the continue image is clicked, it needs to attack 
again. Here's a broken down, simplified order of what needs done.

Attack
Continue
Attack
Continue
Attack
Continue
Attack
Continue
Attack
Continue
Attack
Restart


Here is a sample script that I came up with to execute the above example. This, 
however, was quite slow. Each image click took approximately 1.5 seconds, which 
is extremely slow.
https://paste.ee/p/u6AiT


When I tried to modify the sample script to loop, it wouldn't work for me. It 
would only click one of the images, and then stop without error. Here is a 
sample script that I came up with to execute a looped script that should do the 
same as above.
https://paste.ee/p/aOEva


This brings me to my question, and goal. I'd like the script to click the 
AttackImage whenever it's on screen, and when it's not on screen, click the 
ContinueImage. When neither of those are on screen, it should click the 
RestartImage, which would restart the loop of the script to go back to 
AttackImage, then ContinueImage, etc.

-- 
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 : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


Re: [Sikuli-driver] [Question #268536]: image click on multiple appearances

2015-06-25 Thread Alias
Question #268536 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/268536

Description changed to:
On the webpage that I'm trying to automate, there are three images in
total that need to be clicked. First, an attack image. Second, a
continue image. Third, a restart image. Sikuli should click the attack
image, then move on to the continue image. Once the continue image is
clicked, it needs to attack again. Here's a broken down, simplified
order of what needs done.

Attack
Continue
Attack
Continue
Attack
Continue
Attack
Continue
Attack
Continue
Attack
Restart


Here is a sample script that I came up with to execute the above example. This, 
however, was quite slow. Each image click took approximately 1.5 seconds, which 
is extremely slow.
https://paste.ee/p/u6AiT


When I tried to modify the sample script to loop, it wouldn't work for me. It 
would only click one of the images, and then stop without error. Here is a 
sample script that I came up with to execute a looped script that should do the 
same as above.
https://paste.ee/p/aOEva


This brings me to my question, and goal. I'd like the script to click the 
AttackImage whenever it's on screen, and when it's not on screen, click the 
ContinueImage. When neither of those are on screen, it should click the 
RestartImage, which would restart the loop of the script to go back to 
AttackImage, then ContinueImage, etc. How would I manage to do this 
successfully? 

Oh, and this is sort of related to the question, but why does a
crosshair appear before each click, which I run the script?

-- 
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 : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


Re: [Sikuli-driver] [Question #268536]: image click on multiple appearances

2015-06-30 Thread Eugene Maslov
Question #268536 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/268536

Status: Open => Answered

Eugene Maslov proposed the following answer:
Hi Alias,
I suggest, using observe functions is better in your case:

===8<===

myGame=Region(0,0,800,600)

def myChange(event, region=myGame):

myattack=region.exists("attack.png",1)
mycontinue=region.exists("continue.png",1)
if myattack is not None:
myattack.click()   
elif mycontinue is not None:
mycontinue.click()
else:
myrestart=region.exists("restart.png",1)
myrestart.click()

myGame.onChange(50,myChange)
myGame.observe(30,False)

===8<==

For other click logic, modify if-else conditions in myChange procedure.

-- 
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 : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


Re: [Sikuli-driver] [Question #268536]: image click on multiple appearances

2015-06-30 Thread Eugene Maslov
Question #268536 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/268536

Eugene Maslov posted a new comment:
Sorry, mistyped, a little correction. Zero should be used with exists for 
quicker search, like that:
region.exists("attack.png",0)

-- 
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 : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


Re: [Sikuli-driver] [Question #268536]: image click on multiple appearances

2015-06-30 Thread Eugene Maslov
Question #268536 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/268536

Eugene Maslov proposed the following answer:
Hi Alias,
I suggest, using observe functions is better in your case:

===8<===

myGame=Region(0,0,800,600)

def myChange(event, region=myGame):

myattack=region.exists("attack.png",0)
mycontinue=region.exists("continue.png",0)
if myattack is not None:
myattack.click()
elif mycontinue is not None:
mycontinue.click()
else:
myrestart=region.exists("restart.png",0)
myrestart.click()

myGame.onChange(50,myChange)
myGame.observe(30,False)

===8<==

For other click logic, modify if-else conditions in myChange procedure.

-- 
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 : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


Re: [Sikuli-driver] [Question #268536]: image click on multiple appearances

2015-06-30 Thread Eugene Maslov
Question #268536 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/268536

Eugene Maslov proposed the following answer:
A quicker one:

myGame=Region(0,0,800,600)

def myChange(event, region=myGame):

myattack=region.exists("attack.png",0)  
if myattack is not None:
myattack.click()   
else:
mycontinue=region.exists("continue.png",0)  
if mycontinue is not None:
mycontinue.click()
else:
myrestart=region.exists("restart.png",0)
myrestart.click()

myGame.onChange(50,myChange)
myGame.observe(30,False)

-- 
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 : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp