1
votes

I'm using SikulixIDE 1.1.0 to write a script playing Yugioh game (run on Windows 10 x64). See the main screen: Game screen

I start the game manually and then run the script as below:

switchApp("Yu-Gi-Oh! PC")
click("1477213591920.png")

My expectation is that the link named "DUEL MODE" is clicked to go to the next screen. The cursor always moves to that link, but sometimes it works, sometimes does not.

I check the log and see that Sikuli has sent click command but for some reason, the game not accept it. This is the log:

[log] App.focus: [8020:Yu-Gi-Oh!]
[log] CLICK on L(687,488)@S(0)[0,0 1366x768]

I've already tried:

  • doubleClick instead of click
  • sleep a few seconds
  • hover and click

But all do not work, neither.

3
did you find reason why this happing - bipin
@bipin: not yet, but I use a workaround as Eugene S answered below - Tu Tran

3 Answers

2
votes

I would expect that some of the things you have tried will help but if that's not the case you will need to identify whether the button was actually triggered or not. To do that you have to capture the next screen or any part of it that uniquely identifies it. Then you will use it a loop with a predefined number of attempts and some wait time between them and click more than once if the click didn't work. So generally something like that (pseudo code):

attempts = 3
for attempt in attempts:
    click(button)

    if (nextScreen is available):
        break

    sleep(time)
1
votes

I know it's been a while but I ran into a similar problem recently. The image was found but the click didn't work.

I'm also working on Windows 10 x86_64. The solution was simply to execute the program as administrator. Don't know why but now it's working..

I also had to use the double click instead of simple click for some patterns.

0
votes

In adition to Eugene S Answers, if you are using SikuliX, you can try to Run in Slow Motion. Also, if the image have some effects (like brightness), you can try to use Pattern inside of exists():

if exists(Pattern("DualMode.png").similar(0.6), time_in_seconds):
    click(Pattern("DualMode.png").similar(0.6))

By default, the similar() value is 0.8, so if the image have some effect and for example, the color change every second, you can set a lower value between 0 and 1.

PS: Don't forget to put the pattern inside if exists and click, because if you don't put inside of click(), could throw an Image not found error message.