Jump to content

Recommended Posts

Hello,

im pretty new to coding and i need your help.
i tried to create a script which should do the following steps:

1. search for image
2. if it appears right click on it
3. if it doesnt appear do some mouse clicks
4. search for image again
5. if it appears right click on it
6 if it doesnt appear do some mouse clicks
and so on and so on

my result is:
without the else part the script is fine and it would right click on the image if it appears, however when i added the else part it wouldnt click on the image anymore if it appeared. (i think i use the else function wrong but let me know what you guys think)

 

#include <ImageSearch.au3>

HotKeySet("s", "Start")
HotKeySet("e", "_Exit")

Global $y = 0, $x = 0

Func Start()
   While 1
      sleep (100)
      $file = @DesktopDir & '\Coronet.bmp'
      local $search = _ImageSearch($file, 1, $x, $y, 0)
      if $search = 1 Then
         MouseClick("right", $X, $Y)
         Sleep (50)
         Else
            MouseClick ("left", 929, 691) ;mble window schliessen
            Sleep (200)
            MouseClick ("left", 960, 459) ;Gheed
            Sleep (200)
            MouseClick ("left", 960, 359) ;auf glücksspiel drücken
            Sleep (500)
      EndIf
      Wend
   EndFunc

I appreciate your help!

Link to post
Share on other sites
  • Jos locked this topic
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...