AutoIt Image Search Loop help.

04/19/2014 11:16 tMrz#1
Hello people, how is it going? :)
I have recently created a bot which is supposed to click on specific pictures in Clash of Clans with Bluestacks. My problem is, code does work once. Founds everything, clicks once. But it does not loop even with While 1 at start and WEnd at the end. But once I turn off the bot and re open it, everything starts to work again. If someone can help me out to find my problem, I'll be very glad guys. :handsdown:

Code:
#include <ImageSearch.au3>
#include <GDIPlus.au3>

Global $Paused

HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d


Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Bota ara verildi, devam etmek için PAUSE tuşuna basınız.',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

$fileQ = @ScriptDir & "\gold1.bmp"
$fileW = @ScriptDir & "\gold2.bmp"
$fileE = @ScriptDir & "\gold3.bmp"
$fileR = @ScriptDir & "\gold4.bmp"
$fileT = @ScriptDir & "\gold5.bmp"
$fileY = @ScriptDir & "\gold6.bmp"

;Elixir

$fileA = @ScriptDir & "\pink1.bmp"
$fileS = @ScriptDir & "\pink2.bmp"
$fileD = @ScriptDir & "\pink3.bmp"
$fileF = @ScriptDir & "\pink4.bmp"
$fileG = @ScriptDir & "\pink5.bmp"
$fileH = @ScriptDir & "\pink6.bmp"

;Misc

$fileZ = @ScriptDir & "\dark.bmp"
$fileX = @ScriptDir & "\reload.bmp"

_GDIPlus_Startup()

$X = 0
$Y = 0

;Gold Image

$hImageQ =_GDIPlus_ImageLoadFromFile($fileQ)
$hImageW =_GDIPlus_ImageLoadFromFile($fileW)
$hImageE =_GDIPlus_ImageLoadFromFile($fileE)
$hImageR =_GDIPlus_ImageLoadFromFile($fileR)
$hImageT =_GDIPlus_ImageLoadFromFile($fileT)
$hImageY =_GDIPlus_ImageLoadFromFile($fileY)

;Elixir Image

$hImageA =_GDIPlus_ImageLoadFromFile($fileA)
$hImageS =_GDIPlus_ImageLoadFromFile($fileS)
$hImageD =_GDIPlus_ImageLoadFromFile($fileD)
$hImageF =_GDIPlus_ImageLoadFromFile($fileF)
$hImageG =_GDIPlus_ImageLoadFromFile($fileG)
$hImageH =_GDIPlus_ImageLoadFromFile($fileH)

;Misc Image

$hImageZ =_GDIPlus_ImageLoadFromFile($fileZ)
$hImageX =_GDIPlus_ImageLoadFromFile($fileX)

;Gold hBitmap

$hBitmapQ = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageQ)
$hBitmapW = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageW)
$hBitmapE = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageE)
$hBitmapR = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageR)
$hBitmapT = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageT)
$hBitmapY = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageY)

;Pink hBitmap

$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)
$hBitmapS = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageS)
$hBitmapD = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageD)
$hBitmapF = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageF)
$hBitmapG = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageG)
$hBitmapH = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageH)

;Misc hBitmap

$hBitmapZ = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageZ)
$hBitmapX = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageX)

While 1
$resultQ = _ImageSearch($hBitmapQ, 1, $x, $y, 20)
If $resultQ > 0 Then
   MouseMove($x, $y)
   MouseClick("primary")
EndIf

$resultW= _ImageSearch($hBitmapW, 1, $x, $y, 20)
If $resultW > 0 Then
   MouseMove($x, $y)
   MouseClick("primary")
EndIf

$resultE = _ImageSearch($hBitmapE, 1, $x, $y, 20)
If $resultE > 0 Then
   MouseMove($x, $y)
   MouseClick("primary")
EndIf

$resultR = _ImageSearch($hBitmapR, 1, $x, $y, 20)
If $resultR > 0 Then
   MouseMove($x, $y)
   MouseClick("primary")
EndIf

$resultT = _ImageSearch($hBitmapT, 1, $x, $y, 20)
If $resultT > 0 Then
   MouseMove($x, $y)
   MouseClick("primary")
EndIf

$resultY = _ImageSearch($hBitmapY, 1, $x, $y, 20)
If $resultY > 0 Then
   MouseMove($x, $y)
   MouseClick("primary")
EndIf

;Elixir

$resultA = _ImageSearch($hBitmapA, 1, $x, $y, 20)
If $resultA > 0 Then
   MouseMove($x, $y)
   MouseClick("primary")
EndIf

$resultS= _ImageSearch($hBitmapS, 1, $x, $y, 20)
If $resultS > 0 Then
   MouseMove($x, $y)
   MouseClick("primary")
EndIf

$resultD = _ImageSearch($hBitmapD, 1, $x, $y, 20)
If $resultD > 0 Then
   MouseMove($x, $y)
   MouseClick("primary")
EndIf

$resultF = _ImageSearch($hBitmapF, 1, $x, $y, 20)
If $resultF > 0 Then
   MouseMove($x, $y)
   MouseClick("primary")
EndIf

$resultG = _ImageSearch($hBitmapG, 1, $x, $y, 20)
If $resultG > 0 Then
   MouseMove($x, $y)
   MouseClick("primary")
EndIf

$resultH = _ImageSearch($hBitmapH, 1, $x, $y, 20)
If $resultH > 0 Then
   MouseMove($x, $y)
   MouseClick("primary")
EndIf

;Misc

$resultZ = _ImageSearch($hBitmapZ, 1, $x, $y, 20)
If $resultZ > 0 Then
   MouseMove($x, $y)
   MouseClick("primary")
EndIf

$resultX = _ImageSearch($hBitmapX, 1, $x, $y, 20)
If $resultX > 0 Then
   MouseMove($x, $y)
   MouseClick("primary")
EndIf
WEnd
04/19/2014 12:26 Paraly#2
try this..
PHP Code:
#include <ImageSearch.au3>
#include <GDIPlus.au3>

Global $Paused

HotKeySet
("{PAUSE}""TogglePause")
HotKeySet("{ESC}""Terminate")
HotKeySet("+!d""ShowMessage") ;Shift-Alt-d


Func TogglePause
()
    
$Paused NOT $Paused
    
While $Paused
        sleep
(100)
        
ToolTip('Bota ara verildi, devam etmek için PAUSE tusuna basiniz.',0,0)
    
WEnd
    ToolTip
("")
EndFunc

Func Terminate
()
    Exit 
0
EndFunc

$fileQ 
= @ScriptDir "\gold1.bmp"
$fileW = @ScriptDir "\gold2.bmp"
$fileE = @ScriptDir "\gold3.bmp"
$fileR = @ScriptDir "\gold4.bmp"
$fileT = @ScriptDir "\gold5.bmp"
$fileY = @ScriptDir "\gold6.bmp"

;Elixir

$fileA 
= @ScriptDir "\pink1.bmp"
$fileS = @ScriptDir "\pink2.bmp"
$fileD = @ScriptDir "\pink3.bmp"
$fileF = @ScriptDir "\pink4.bmp"
$fileG = @ScriptDir "\pink5.bmp"
$fileH = @ScriptDir "\pink6.bmp"

;Misc

$fileZ 
= @ScriptDir "\dark.bmp"
$fileX = @ScriptDir "\reload.bmp"

_GDIPlus_Startup()

$X 0
$Y 
0

;Gold Image

$hImageQ 
=_GDIPlus_ImageLoadFromFile($fileQ)
$hImageW =_GDIPlus_ImageLoadFromFile($fileW)
$hImageE =_GDIPlus_ImageLoadFromFile($fileE)
$hImageR =_GDIPlus_ImageLoadFromFile($fileR)
$hImageT =_GDIPlus_ImageLoadFromFile($fileT)
$hImageY =_GDIPlus_ImageLoadFromFile($fileY)

;
Elixir Image

$hImageA 
=_GDIPlus_ImageLoadFromFile($fileA)
$hImageS =_GDIPlus_ImageLoadFromFile($fileS)
$hImageD =_GDIPlus_ImageLoadFromFile($fileD)
$hImageF =_GDIPlus_ImageLoadFromFile($fileF)
$hImageG =_GDIPlus_ImageLoadFromFile($fileG)
$hImageH =_GDIPlus_ImageLoadFromFile($fileH)

;
Misc Image

$hImageZ 
=_GDIPlus_ImageLoadFromFile($fileZ)
$hImageX =_GDIPlus_ImageLoadFromFile($fileX)

;
Gold hBitmap

$hBitmapQ 
_GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageQ)
$hBitmapW _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageW)
$hBitmapE _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageE)
$hBitmapR _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageR)
$hBitmapT _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageT)
$hBitmapY _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageY)

;
Pink hBitmap

$hBitmapA 
_GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)
$hBitmapS _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageS)
$hBitmapD _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageD)
$hBitmapF _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageF)
$hBitmapG _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageG)
$hBitmapH _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageH)

;
Misc hBitmap

$hBitmapZ 
_GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageZ)
$hBitmapX _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageX)

While 
1
$resultQ 
_ImageSearch($hBitmapQ1$x$y20)
If 
$resultQ 0 Then
   MouseMove
($x$y)
   
MouseClick("primary")
   
$resultQ 0
EndIf

$resultW_ImageSearch($hBitmapW1$x$y20)
If 
$resultW 0 Then
   MouseMove
($x$y)
   
MouseClick("primary")
   
$resultW 0
EndIf

$resultE _ImageSearch($hBitmapE1$x$y20)
If 
$resultE 0 Then
   MouseMove
($x$y)
   
MouseClick("primary")
   
$resultE 0
EndIf

$resultR _ImageSearch($hBitmapR1$x$y20)
If 
$resultR 0 Then
   MouseMove
($x$y)
   
MouseClick("primary")
   
$resultR 0
EndIf

$resultT _ImageSearch($hBitmapT1$x$y20)
If 
$resultT 0 Then
   MouseMove
($x$y)
   
MouseClick("primary")
   
$resultT 0
EndIf

$resultY _ImageSearch($hBitmapY1$x$y20)
If 
$resultY 0 Then
   MouseMove
($x$y)
   
MouseClick("primary")
   
$resultY 0
EndIf

;
Elixir

$resultA 
_ImageSearch($hBitmapA1$x$y20)
If 
$resultA 0 Then
   MouseMove
($x$y)
   
MouseClick("primary")
   
$resultA 0
EndIf

$resultS_ImageSearch($hBitmapS1$x$y20)
If 
$resultS 0 Then
   MouseMove
($x$y)
   
MouseClick("primary")
   
$resultS 0
EndIf

$resultD _ImageSearch($hBitmapD1$x$y20)
If 
$resultD 0 Then
   MouseMove
($x$y)
   
MouseClick("primary")
   
$resultD 0
EndIf

$resultF _ImageSearch($hBitmapF1$x$y20)
If 
$resultF 0 Then
   MouseMove
($x$y)
   
MouseClick("primary")
   
$resultF 0
EndIf

$resultG _ImageSearch($hBitmapG1$x$y20)
If 
$resultG 0 Then
   MouseMove
($x$y)
   
MouseClick("primary")
   
$resultG 0
EndIf

$resultH _ImageSearch($hBitmapH1$x$y20)
If 
$resultH 0 Then
   MouseMove
($x$y)
   
MouseClick("primary")
   
$resultH 0
EndIf

;
Misc

$resultZ 
_ImageSearch($hBitmapZ1$x$y20)
If 
$resultZ 0 Then
   MouseMove
($x$y)
   
MouseClick("primary")
   
$resultZ 0
EndIf

$resultX _ImageSearch($hBitmapX1$x$y20)
If 
$resultX 0 Then
   MouseMove
($x$y)
   
MouseClick("primary")
   
$resultX 0
EndIf
WEnd 
04/19/2014 13:41 tMrz#3
I just tried the code you gave me man, but nothing is happening again after the first click :(

Let me give you some more information about this man. In this game, once the first click happens, the image disappears after the click and then after a while, the game produces same exact image. What I want is to make those pictures clicked right away after they appear within 2-3 second. I tried sleep option too but it didn't work.

The thing is, this simply happens in pixel search; once the pixel is found bot clicks it right away, but then it finds the same pixel in another location where it is not suppose to find and then clicks there. Maybe I can avoid clicking that by narrowing the search area but the developers are wise enough to use a huge variety of colors in the game so bot might find the pixel in another place.

My idea for using image search is to avoid these kind of conflicts, be more strict on what it is looking for instead of one pixel.

I hope we can sort this out, thanks in advance.
04/19/2014 14:51 Paraly#4
I did a shorter version of your script 400 lines to 90 lines :D
PHP Code:
#include <ImageSearch.au3>
#include <GDIPlus.au3>

Global $Paused

HotKeySet
("{PAUSE}""TogglePause")
HotKeySet("{ESC}""Terminate")
HotKeySet("+!d""ShowMessage") ;Shift-Alt-d


Func TogglePause
()
    
$Paused NOT $Paused
    
While $Paused
        sleep
(100)
        
ToolTip('Bota ara verildi, devam etmek için PAUSE tusuna basiniz.',0,0)
    
WEnd
    ToolTip
("")
EndFunc

Func Terminate
()
    Exit 
0
EndFunc

Dim $file
[14]
Dim $hImage[14]
Dim $hBitmap[14]

$file[0] = @ScriptDir "\gold1.bmp"
$file[1] = @ScriptDir "\gold2.bmp"
$file[2] = @ScriptDir "\gold3.bmp"
$file[3] = @ScriptDir "\gold4.bmp"
$file[4] = @ScriptDir "\gold5.bmp"
$file[5] = @ScriptDir "\gold6.bmp"

;Elixir

$file
[6] = @ScriptDir "\pink1.bmp"
$file[7] = @ScriptDir "\pink2.bmp"
$file[8] = @ScriptDir "\pink3.bmp"
$file[9] = @ScriptDir "\pink4.bmp"
$file[10] = @ScriptDir "\pink5.bmp"
$file[11] = @ScriptDir "\pink6.bmp"

;Misc

$file
[12] = @ScriptDir "\dark.bmp"
$file[13] = @ScriptDir "\reload.bmp"

_GDIPlus_Startup()

$X 0
$Y 
0

;Image
$i 
0
Do
$hImage[$i] =_GDIPlus_ImageLoadFromFile($file[$i])
$i += 1
Until $i 
UBound($file)

;
hBitmap
$i 
0
Do
$hBitmap[$i] = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage[$i])
$i += 1
Until $i 
UBound($file)


;
Main
While 1
$i 
0
Do
    
$found _SearchImage($hBitmap[$i])
    If 
$found True Then
        Sleep
(Random(2000,3000,1)
    EndIf
    
$i += 1
Until $i 
UBound($hBitmap)
Sleep(25)
WEnd



Func _SearchImage
($Bitmap)
    
Local $x$y
    Local $result 
_ImageSearch($hBitmap1$x$y20)
    If 
$result 0 Then
        MouseClick
("LEFT",$x,$y)
        Return 
True
    
Else
        Return 
False
    
EndIf
EndFunc 
04/19/2014 15:27 tMrz#5
Tho it is shorter a lot, it is sad to say and see that it is not working :( I tried your coding on the base images and still no go, although mine is still working till one point as mentioned before. Any suggestions?

I have tweaked the code a little bit more. Even it is still long, now I got some more ideas. According to this code, on first run every image is found and clicked, but then the same images are not being found. Dark Elixir is the fastest one to show up, but even it is on the screen the script doesn't recognize it's image and says the image is not found.

Code:
#include <ImageSearch.au3>
#include <GDIPlus.au3>

Global $Paused

HotKeySet(".", "Bot")
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Bota ara verildi, devam etmek için PAUSE tusuna basiniz.',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

$fileQ = @ScriptDir & "\gold1.bmp"
$fileW = @ScriptDir & "\gold2.bmp"
$fileE = @ScriptDir & "\gold3.bmp"
$fileR = @ScriptDir & "\gold4.bmp"
$fileT = @ScriptDir & "\gold5.bmp"
$fileY = @ScriptDir & "\gold6.bmp"

;Elixir

$fileA = @ScriptDir & "\pink1.bmp"
$fileS = @ScriptDir & "\pink2.bmp"
$fileD = @ScriptDir & "\pink3.bmp"
$fileF = @ScriptDir & "\pink4.bmp"
$fileG = @ScriptDir & "\pink5.bmp"
$fileH = @ScriptDir & "\pink6.bmp"

;Misc

$fileZ = @ScriptDir & "\dark.bmp"
$fileX = @ScriptDir & "\reload.bmp"

_GDIPlus_Startup()

$X = 0
$Y = 0

;Gold Image

$hImageQ =_GDIPlus_ImageLoadFromFile($fileQ)
$hImageW =_GDIPlus_ImageLoadFromFile($fileW)
$hImageE =_GDIPlus_ImageLoadFromFile($fileE)
$hImageR =_GDIPlus_ImageLoadFromFile($fileR)
$hImageT =_GDIPlus_ImageLoadFromFile($fileT)
$hImageY =_GDIPlus_ImageLoadFromFile($fileY)

;Elixir Image

$hImageA =_GDIPlus_ImageLoadFromFile($fileA)
$hImageS =_GDIPlus_ImageLoadFromFile($fileS)
$hImageD =_GDIPlus_ImageLoadFromFile($fileD)
$hImageF =_GDIPlus_ImageLoadFromFile($fileF)
$hImageG =_GDIPlus_ImageLoadFromFile($fileG)
$hImageH =_GDIPlus_ImageLoadFromFile($fileH)

;Misc Image

$hImageZ =_GDIPlus_ImageLoadFromFile($fileZ)
$hImageX =_GDIPlus_ImageLoadFromFile($fileX)

;Gold hBitmap

$hBitmapQ = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageQ)
$hBitmapW = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageW)
$hBitmapE = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageE)
$hBitmapR = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageR)
$hBitmapT = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageT)
$hBitmapY = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageY)

;Pink hBitmap

$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)
$hBitmapS = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageS)
$hBitmapD = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageD)
$hBitmapF = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageF)
$hBitmapG = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageG)
$hBitmapH = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageH)

;Misc hBitmap

$hBitmapZ = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageZ)
$hBitmapX = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageX)



While 1

;Reload

$resultX = _ImageSearch($hBitmapX, 1, $x, $y, 20)
If $resultX = 1 Then
   ToolTip('Reload found',0,0)
   MouseMove($x, $y)
   MouseClick("primary")
EndIf
Sleep(5000)
If $resultX = 0 Then
   ToolTip('Reload not found',0,0)
EndIf
Sleep(5000)

;Dark Elixir

$resultZ = _ImageSearch($hBitmapZ, 1, $x, $y, 20)
If $resultZ = 1 Then
   ToolTip('Dark Elixir found',0,0)
   MouseMove($x, $y)
   MouseClick("primary")
EndIf
Sleep(5000)
If $resultZ = 0 Then
   ToolTip('Dark Elixir not found',0,0)
EndIf
Sleep(5000)



;Gold

$resultQ = _ImageSearch($hBitmapQ, 1, $x, $y, 20)
If $resultQ = 1 Then
   ToolTip('Gold 1 found',0,0)
   MouseMove($x, $y)
   MouseClick("primary")
EndIf
Sleep(1000)
If $resultQ = 0 Then
   ToolTip('Gold 1 not found',0,0)
EndIf
Sleep(3000)

$resultW = _ImageSearch($hBitmapQ, 1, $x, $y, 20)
If $resultW = 1 Then
   ToolTip('Gold 2 found',0,0)
   MouseMove($x, $y)
   MouseClick("primary")
EndIf
Sleep(1000)
If $resultW = 0 Then
   ToolTip('Gold 2 not found',0,0)
EndIf
Sleep(3000)

$resultE = _ImageSearch($hBitmapQ, 1, $x, $y, 20)
If $resultE = 1 Then
   ToolTip('Gold 3 found',0,0)
   MouseMove($x, $y)
   MouseClick("primary")
EndIf
Sleep(1000)
If $resultE = 0 Then
   ToolTip('Gold 3 not found',0,0)
EndIf
Sleep(3000)

$resultR = _ImageSearch($hBitmapQ, 1, $x, $y, 20)
If $resultR = 1 Then
   ToolTip('Gold 4 found',0,0)
   MouseMove($x, $y)
   MouseClick("primary")
EndIf
Sleep(1000)
If $resultR = 0 Then
   ToolTip('Gold 4 not found',0,0)
EndIf
Sleep(3000)

$resultT = _ImageSearch($hBitmapQ, 1, $x, $y, 20)
If $resultT = 1 Then
   ToolTip('Gold 5 found',0,0)
   MouseMove($x, $y)
   MouseClick("primary")
EndIf
Sleep(1000)
If $resultT = 0 Then
   ToolTip('Gold 5 not found',0,0)
EndIf
Sleep(3000)

$resultY = _ImageSearch($hBitmapQ, 1, $x, $y, 20)
If $resultY = 1 Then
   ToolTip('Gold 6 found',0,0)
   MouseMove($x, $y)
   MouseClick("primary")
EndIf
Sleep(1000)
If $resultY = 0 Then
   ToolTip('Gold 6 not found',0,0)
EndIf
Sleep(3000)

;Elixir

$resultA = _ImageSearch($hBitmapA, 1, $x, $y, 20)
If $resultA > 0 Then
   MouseMove($x, $y)
   MouseClick("primary")
EndIf

$resultS= _ImageSearch($hBitmapS, 1, $x, $y, 20)
If $resultS > 0 Then
   MouseMove($x, $y)
   MouseClick("primary")
EndIf

$resultD = _ImageSearch($hBitmapD, 1, $x, $y, 20)
If $resultD > 0 Then
   MouseMove($x, $y)
   MouseClick("primary")
EndIf

$resultF = _ImageSearch($hBitmapF, 1, $x, $y, 20)
If $resultF > 0 Then
   MouseMove($x, $y)
   MouseClick("primary")
EndIf

$resultG = _ImageSearch($hBitmapG, 1, $x, $y, 20)
If $resultG > 0 Then
   MouseMove($x, $y)
   MouseClick("primary")
EndIf

$resultH = _ImageSearch($hBitmapH, 1, $x, $y, 20)
If $resultH > 0 Then
   MouseMove($x, $y)
   MouseClick("primary")
EndIf
Wend
I have read about something _WaitForImageSearch but I'm not sure if that is a workaround. If anyone got any idea at all, please feel free to share :)
Thanks in advance.
10/25/2014 12:54 Rastal#6
I can assist you with this if you like. The only question I have for you is what are your bitmaps of (are they of the mines and extractors)? As it is, I cannot get your code to work at all.
11/15/2014 09:47 PD6ty-niner#7
I have presently placed the .au3 and its .dll of Imagesearch along with a .bmp file for it to search and click.
But when the code runs it does not click on anything and it does not return an error message. Im currently running the code in x86 therefore I'm using 32bit Imagesearch. The .bmp is saved in 16 bit. So where am i going wrong?
11/18/2014 05:40 flumio#8
Just check with a simple MsgBox if you still in the loop or not. So you will get after the first click an result, and know wat to do after this.