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.
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
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.
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
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.
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.
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?
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()
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"