Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 19:18

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



AutoIt Image Search Loop help.

Discussion on AutoIt Image Search Loop help. within the AutoIt forum part of the Coders Den category.

Reply
 
Old   #1
 
tMrz's Avatar
 
elite*gold: 0
Join Date: Feb 2010
Posts: 29
Received Thanks: 10
Exclamation AutoIt Image Search Loop help.

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.

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
tMrz is offline  
Old 04/19/2014, 12:26   #2
 
Paraly's Avatar
 
elite*gold: 27
Join Date: Sep 2009
Posts: 5,609
Received Thanks: 1,596
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 
Paraly is offline  
Thanks
1 User
Old 04/19/2014, 13:41   #3
 
tMrz's Avatar
 
elite*gold: 0
Join Date: Feb 2010
Posts: 29
Received Thanks: 10
Thumbs up

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.
tMrz is offline  
Old 04/19/2014, 14:51   #4
 
Paraly's Avatar
 
elite*gold: 27
Join Date: Sep 2009
Posts: 5,609
Received Thanks: 1,596
I did a shorter version of your script 400 lines to 90 lines
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 
Paraly is offline  
Thanks
1 User
Old 04/19/2014, 15:27   #5
 
tMrz's Avatar
 
elite*gold: 0
Join Date: Feb 2010
Posts: 29
Received Thanks: 10
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.
tMrz is offline  
Old 10/25/2014, 12:54   #6
 
elite*gold: 0
Join Date: Feb 2008
Posts: 1
Received Thanks: 0
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.
Rastal is offline  
Old 11/15/2014, 09:47   #7
 
elite*gold: 0
Join Date: Nov 2014
Posts: 1
Received Thanks: 0
The ImageSearch.au3 files and DLL

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?
PD6ty-niner is offline  
Old 11/18/2014, 05:40   #8
 
flumio's Avatar
 
elite*gold: 50
Join Date: Feb 2009
Posts: 765
Received Thanks: 927
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.
flumio is offline  
Reply

Tags
autoit, image search, imagesearch, loop


Similar Threads Similar Threads
autoit image search
05/23/2013 - Metin2 Private Server - 3 Replies
Hey :D, ich hab mir mit AutoIt was geschrieben und habe dabei imagesearch benutzt, ich will die exe aber weiterschicken ohne, dass jemand die ganze bilder sieht ich dafür benötigt habe, gibts da ne einfache Lösung die bilder mit in die exe einzubinden? wenn ihr mehr infos zum script braucht sagt bescheid ;-). LG Tom
how to make a loop (image included)
02/19/2012 - AutoIt - 8 Replies
i was trying to make a loop like this http://p73.img-up.net/looop990ti.png here is my code Func _target()
[UDF] Autoit Image Search
10/01/2010 - AutoIt - 8 Replies
We dont like racist forum fuc|< you.
Autoit - loop TAB key?
01/11/2010 - Perfect World - 4 Replies
Hi everyone :confused: I have try all night to make a tab key work... here the code; ********************************************** $title = "Element Client" $game=WinActivate($title, "") WinSetOnTop($title, "", 0) Sleep(1000) $red = "0xFF0000"



All times are GMT +1. The time now is 19:19.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.