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:
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