Make sikuli look for certain phrases and click offset link accordingly

Asked by Naus Town

So on this website there are certain games we want our bot to spectate.

Here is how it looks like: http://i61.tinypic.com/2u5cnzt.png
from (www.untap.in) Free to play!

At first the game must be a "MTG" game.
The spectating bot should find phrases like (ALL case UNsensitive): "bng", "botg", "born" and click "Spectate" accordingly.
If there are non found then it should look for (ALL case UNsensitive): "std", "standard" and click "Spectate" accordingly.
When there is still nothing found it goes on and just clicks a random one.

So that's the code until now:
while True: # main loop
 exists(Pattern("1-2.png").similar(0.85),99999) # Wait for Games
 click(Pattern("1-3.png").similar(0.85)) # Click on Games
 exists(Pattern("autoSpectate.png").similar(0.80),99999) # Wait for Spectate
 import random
 click(random.choice(list(findAll(Pattern("autoSpectate-3.png").similar(0.80))))) # Click on Spectate
 exists(Pattern("autoturn-1.png").similar(0.85),99999) # Wait for Turn
 while exists(Pattern("autoturn-1.png").similar(0.85)): # Secondary search loop
       if exists(Pattern("1391360914254.png").similar(0.85)): # TEST " player has left game
           Region(1800,1051,110,28).exists(Pattern("autlev-2.png").similar(0.33),99999) # Look for Exit Name
           Region(1800,1051,110,28).hover(Pattern("autlev-2.png").similar(0.33)) # find exit lobby button in proper region
           exists(Pattern("backtolob-1.png").similar(0.85),99999)
           click(Pattern("backtolob.png").similar(0.85))
           break # end search loop and return to main loop.
       else:
           wait(2) # wait period before restarting loop
           continue # continue search loop if "player has left game" is not found.

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
Naus Town (wertzugeld) said :
#1

Is there also a possibility to change all the image recognition to real text recognition?

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

I just made a short test with Sikuli's OCR feature:

the respective column was OCR'd like this:
modemOf EDH
EDH test new dec
dont enter
STD BOTG

as you can see:
the line containing
standard+bng

was not recognized at all.

So I guess, even if you might try with Sikuli's text feature in the current shape, you will not get very happy.
But you should at least give it a try:
Region.find("botg")
Region.find("BOTG")
...

Revision history for this message
Naus Town (wertzugeld) said :
#3

So how do I make it click the right Spectate?

Revision history for this message
Naus Town (wertzugeld) said :
#4

Thanks RaiMan, that solved my question.