Jump to content
tommyoo

Repeat Imagesearch

Recommended Posts

tommyoo

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!

Share this post


Link to post
Share on other sites
tommyoo

yes it is.

well i didnt know that. excuse me then o:)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×