mouse click not 100% succesful

Asked by JD

Hi guys,
I have been trying to teach myself sikuli and jython by trying myself at writing a program to play bejeweled for me . Sort of reverse engineering the bejeweled script that is on the sikuli video section (I have 0 coding experience, but with the help of the people here on LaunchPad especially RaiMan I have muddled my way through). I have the most basic up and running (scans bejeweled in about 5 seconds (best i could manage) and does a move (prioritizes 5 in a row over 4 over 3). However i find that the program gets stuck very often because it seems the click on the first gem is not successful 100% of the times.

I have the code:
  def perform_Clicks((a,b),(c,d)):
        mouseMove(Location(a,b))
        mouseDown(Button.LEFT)
        mouseUp()
        mouseMove(Location(c,d))
        mouseDown(Button.LEFT)
        mouseUp()

with a,b being the coordinates for gem1, and c,d the coordinates for gem2.
The mouse moves to the right gem, but the gem only becomes 'highlighted' due to a click about 50% of the times.
I tried putting a wait command between the move and the click, but it didn't improve things.
When i click on the gem by my mouse-pad it is 100% successful on the first try.

Any ideas how I can improve this?

Question information

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

what happens, when using

click(Location(a,b))

instead of

        mouseMove(Location(a,b))
        mouseDown(Button.LEFT)
        mouseUp()

Revision history for this message
JD (keelbo) said :
#2

Sadly that doesn't seem to be working either. I can see it trying to click the correct gems, and I'm pretty sure it is actually clicking, but it just doesn't seem to register with the game. (http://www.memory-improvement-tips.com/free-bejeweled-game.html). Not sure what is going on there.

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

tried with the game in Safari on Mac and have no problem clicking the gems.

If you are on Windows:
- run your script as admin
- have the latest flash version
- use Chrome or Firefox as browser

Revision history for this message
JD (keelbo) said :
#4

Thanks for the tip. It is a bit strange. It does actually work perfectly in Safari (I was using Firefox). Any ideas why it doesn't work in Firefox, my flash player is up to date.
Anyway, i guess I will work on the script using Safari to run the game.

Thank you heaps

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

On Mac FF works too.

So must be some weird Windows/FF/Flash/Java(Robot) problem.