OSX 10.10. Mouse clicks in a loop failing / slowing down

Asked by Pak Lam

Hi,

I was writing a loop clicking on a game board which should help to me click 24 buttons, here's the code:

        try:
            gbc=find(Pattern("1431440461493.png").similar(0.35)).getCenter()
            print "Found gameboard"
            for x in range (0,24):
                hover(gbc.offset(xtuple[x],ytuple[x]))
                for m in xrange(2):
                    mouseDown(Button.LEFT)
                    mouseUp(Button.LEFT)
                print "Click: (",xtuple[x],", ",ytuple[x],")"
        except Findfailed:
            print "findgameboardagain"

and the above codes is inside a while loop...
however while i run the code, it can do the clicking sometimes, but just 1~2 loops.
afterward the whole program is stuck in some part of the 24 loops click, sometimes while i press "cmd + tab" and it moves again...
and sometimes it just don't move... in that case i have to stop the script manually.

here's the messages:

Let's find gameboard
Found gameboard

Click: ( -145 , -150 )

Click: ( -68 , -148 )

Click: ( 2 , -144 )

Click: ( 83 , -148 )

Click: ( 156 , -147 )

java.lang.InterruptedException: sleep interrupted
at java.lang.Thread.sleep(Native Method)
at java.awt.Robot.delay(Robot.java:535)
at java.awt.Robot.autoDelay(Robot.java:521)
at java.awt.Robot.afterEvent(Robot.java:471)
at java.awt.Robot.mouseRelease(Robot.java:315)
at org.sikuli.script.RobotDesktop.mouseUp(RobotDesktop.java:110)
at org.sikuli.script.Mouse.up(Mouse.java:365)
at org.sikuli.script.Mouse.up(Mouse.java:349)
at org.sikuli.script.Mouse.reset(Mouse.java:100)
at org.sikuli.script.Sikulix.cleanUp(Sikulix.java:197)
at org.sikuli.ide.SikuliIDE$ButtonRun$1.run(SikuliIDE.java:2252)

i still can't figure out why sometimes it clicks all 24 points, but sometimes just stop without any warnings.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

what version of Sikuli?
what system?

Revision history for this message
Pak Lam (pak1123) said :
#2

SikulixIDE 1.1.0
Mac OSX 10.10.2

Revision history for this message
Pak Lam (pak1123) said :
#3

And i also tried to change the clicking to:

for x in range (0,24):
                switchApp("Google Chrome")
                click(gbc.offset(xtuple[x],ytuple[x]))
                print "Click: (",xtuple[x],", ",ytuple[x],")"

still same...

Revision history for this message
Best RaiMan (raimund-hocke) said :
#4
Revision history for this message
Pak Lam (pak1123) said :
#5

I was trying the mentioned workaround...

1. use this to start the IDE from a command line:
java -jar /Applications/SikuliX.app/Contents/Java/sikulix.jar

but the whole script is not working...

2. or use the IDE as usual, but do not run from inside the IDE, but in parallel from a Terminal session (command line)
<path to your setup folder>/runsikulix -r yourScript.sikuli

i can't find the runsikulix.. after i run sikulixsetup-1.1.0.jar to generate the SikuliX.app, no any other cmd had came out

Revision history for this message
RaiMan (raimund-hocke) said :
#6

sure you have the latest build?

Might be, that it works with that anyway.

Revision history for this message
Pak Lam (pak1123) said :
#7

Thanks RaiMan, that solved my question.

Revision history for this message
Pak Lam (pak1123) said :
#8

I just got the latest build and it's fixed!! :) many thanks for your support!

Revision history for this message
RaiMan (raimund-hocke) said :
#9

thanks for confirmation.