Wildpal

Image Search

5 posts in this topic

Im new to autoit and can´t get image search to work.

#include <ImageSearch.au3>

HotKeySet("{ESC}", "Terminate")
HotKeySet("!a", "Start")

MsgBox(0, "Starting Up", "Starting, use ESCAPE to quit, and Alt + A to start searching.")

While 1
   sleep(1)
WEnd

Func Start()
   While 1
      $result =_ImageSearch("main.png",1 ,$x1, $y1, 0)
      If $result= 1 Then
         MouseClick("LEFT",$x ,$y)
         sleep(500)
      EndIf
   WEnd
EndFunc

Func Terminate()
   exit 1
EndFunc

result =_ImageSearch("main.png",1 ,$x1, $y1, 0)
$result =_ImageSearch("main.png",1 ,^ ERROR

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Read that a little wrong on my phone.  Try defining $x1 and $y1 before using them.  Also

MouseClick("LEFT",$x ,$y)

Should be 

MouseClick("LEFT",$x1 ,$y1)
Edited by kaisies

Share this post


Link to post
Share on other sites

Thank you for the help but now a new problem appeared.

#include <ImageSearch.au3>

HotKeySet("{ESC}", "Terminate")
HotKeySet("!a", "Start")

MsgBox(0, "Starting Up", "Starting, use ESCAPE to quit, and Alt + A to start searching.")

$x1 = 0
$y1 = 0

While 1
   sleep(1)
WEnd

Func Terminate()
   exit 1
EndFunc

Func Start()
   While 1
      $result =_ImageSearch("main.png",1 ,$x1, $y1, 0)
      If $result = 1 Then
         MouseClick("LEFT",$x1 ,$y1)
         sleep(500)
      EndIf
   WEnd
EndFunc

if $result[0]="0" then return 0

Share this post


Link to post
Share on other sites

Unless you include the error you are receiving, I can only guess what your problem is.  My guess right now is you don't know how to read errors.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now